Hi, i use the follwing code to load and open a file and save it into a buffer(bufferDes). I have no problem opening the file, but my emulator crashes when it exceeds. I realise that this happen everytime when i try to load a file: Below is the function i use to load the file. Is there any problem or i forgot to close something so it crashes?
TPtr8* CHelloWorldAppView::LoadFile(const TDesC& filename) {
int size=0;
RFs iRFs;
RFile iFile;
TPtr8* bufferDes;
TFileName aPath=BaflUtils:😃riveAndPathFromFullName(
CEikonEnv::Static()->EikAppUi()->Application()->AppFullName());
aPath.Append(filename);
iRFs.Connect();
int temp=iFile.Open(iRFs, aPath, EFileStream);
iFile.Size(size);
bufferDes = new TPtr8(new TUint8[size], size);
iFile.Read(*bufferDes, size);
iFile.Close();
iRFs.Close();
return bufferDes;
}
Hope you can help, i am totally helpless.
Thanks.
zhen