Cannot open, create or replace file ( s60 3rd ed )

Login to reply to this topic.
Fri, 2007-01-05 16:24
Joined: 2006-12-13
Forum posts: 25
Here is my code

Code:
RFs iFs;
RFile iFile;
TInt aStatus=0;

iFs.Connect();
aStatus = iFile.Replace(iFs, _L("filename"), EFileWrite);
iFile.Close();
iFs.Close();

In all contexts (replace 'Replace' with 'Open' or 'Create' ...) it turns out that aStaus=-12. (System wide errorcode which ways that the path cannot be found)

I belive that a file in my apps private directory will be created, but only an error occurs.....


Magnus

Fri, 2007-01-05 16:40
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Re: Cannot open, create or replace file ( s60 3rd ed )
What is the value of filename ?
(should be the full path to your private directory and the filename)

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Sat, 2007-01-06 20:55
Joined: 2006-12-13
Forum posts: 25
Re: Cannot open, create or replace file ( s60 3rd ed )
Thanks eric for your answer.

Now I try this:

Code:
RFs iFs;
RFile iFile;
TInt aStatus=0;

TBuf<256> filepath;
iFs.PrivatePath(filepath);                    //  NOTE
filepath.Append(_L("filename.txt"));   // NOTE

iStatus = iFile.Replace(iFs, filepath, EFileWrite);

but 'iStatus' still has the value -12 after iFile.Replace(...);

Mon, 2007-01-08 05:38
Joined: 2005-12-07
Forum posts: 58
Re: Cannot open, create or replace file ( s60 3rd ed )
HI,

  Check whether the path is correct by printing it...If you have any spelling mistakes in the path you will get the -12 error....

Regards,
peter
Mon, 2007-01-08 07:33
Joined: 2004-12-03
Forum posts: 276
Re: Cannot open, create or replace file ( s60 3rd ed )
-12 -> Indicates  "path not found".

And RFile::Replace wants the directory to be present before creating the file.

Therefore I suspect that the private directory is not created in your case. By default no private directory is created. You have to copy any file (in case of an installation) in the private folder or you have to manually(or programaticaly) create it.

In emulator just run your program after creating the directory.

Cheers
Dennis

Today is a gift by GOD, that's why it is called the present.

Mon, 2007-01-08 10:05
Joined: 2006-12-13
Forum posts: 25
Re: Cannot open, create or replace file ( s60 3rd ed )
Thanks dennis_george, you are absolutely right.

I realized that the problem was that the diretory dint exist late saturday.


----> the most stupid lack of understanding takes longest time conquer <----
  • Login to reply to this topic.