File read and write problem!!
| Tue, 2006-11-07 06:49 | |
|
Hi all,
I want to store a single flag value in a file so that each time program will refer that value and go ahead. I have referred some threads in this as well as other forums. but cannot get the full idea. Kindly help me to solve, how to write the value in file and read it from file?? Best regards |
|






Forum posts: 26
_LIT8(KData, "A1=12345&");
//...
RFs fs;
fs.Connect();
CleanupClosePushL(fs);
RFile file;
TInt err = file.Open(fs, KFileName, EFileShareAny | EFileWrite);
if(err != KErrNone)
{
err = file.Create(fs, KFileName, EFileShareAny | EFileWrite);
}
if (!err)
{
CleanupClosePushL(file);
User::LeaveIfError(file.Write(KData));
CleanupStack::PopAndDestroy(); // file
}
CleanupStack::PopAndDestroy(); // fs
but that comes in winscw\c path. (as I use 7.0 and 2nd sdk) I also did armi build but no such file is created in another folder.
So what should be done to create file in real device. I mean what should be the path for that. (currently my path is _LIT(KFileName, "c:\\test.txt"); )
Regards
Forum posts: 62
you can create a directory using
and your file path should be
hope this help you
rgrds
Badshah
Forum posts: 26
but I got the solution for that. The path is same for emulator and real device!
I have another problem of reading file
I tried this
TDes8 *aDes;
file.Read(*aDes); but not successfull yet!
I want to store the string of file in one variable. How can I achiece this??
Kindly help
Best regards
Forum posts: 62
dont use the TDes8 as it is..
you can use a TBuf8 instead.
try this
file.Read(aDes);
if your file contains some large amount of data,you can use a HBufC8 object instead of Tbuf8.
regards
Badshah
Forum posts: 26
Thanx..I got it!
Regards