Well, this is my peice of code and it works for me.
Code:
void ActiveRead::ConstructL()
{
iFs.Connect();
_LIT(KFile,"c:\\system\\apps\\MyXmlParser\\test.jpg");
_LIT(KFile1,"c:\\system\\apps\\MyXmlParser\\test1.jpg");
aFile.Replace(iFs,KFile1,EFileWrite);
iFile.Open(iFs,KFile,EFileRead);
iFile.Size(iSizeRead);
m_pTmpBuffer = HBufC8::NewL(iSizeRead);
// mpuntBuffer is TPtr8 and i initialise it in the constructor.
mpuntBuffer.Set(m_pTmpBuffer->Des());
aFile.Size(iSizeWrite);
ReadFile();
}
Code:
void ActiveRead::ReadFile()
{
iFile.Read(mpuntBuffer, 100,iStatus);
SetActive();
}
Code:
void ActiveRead::RunL()
{
if (iStatus == KErrNone)
{
if ( m_pTmpBuffer->Des().Length() == iSizeRead )
{
iFile.Close();
delete m_pTmpBuffer;
m_pTmpBuffer = 0;
}
else
{
// Read the next chunk of the file.
aFile.Write(mpuntBuffer);
aFile.Size(iSizeWrite);
if(iSizeWrite!=iSizeRead)
ReadFile();
}
}
else
{
TBuf<10>abuf;
abuf.AppendNum(iStatus.Int());
User::InfoPrint(abuf);
}
}
Regards,
Priju