filesystems - iPhone - fopen and pathForResource - Permission denied -


I tried to open a file directly to fopen ("/ test.txt", "w +") Is ; It works on the simulator but does not work on the iPhone.

Then I have tried this:

  NSString * path = [[NSBundle mainBundle] pathForResource: @ "GirlName.txt" type: zero]; NSLog (path); Feature = Fopen ([Path SistringUzching Encoding: 1], "W +"); If (fichier! = NULL) {...} else {perror ("error"); }  

I get permission in the console:

  2009-07-24 17:17 17: 27.415 Madomocell [8 9 7: 20b] / var / Mobile / application / ... / .... ap / golnam Commentary error: denied by permission  

Can you tell me what is wrong?

You can not open a file within the application bundle and write it ("w +") Can create.

This same code will probably work (if you have changed "R" mode then

If you need a writable text file, you can write one In the qualified directory, I will do something like this:

  // method writes a string in a text file - (zero) writeToTextFile {// Get the directory of the document: NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString * Document Directory = [Path ItemOutIndex: 0]; // Write a file name to write the data to use the document directory: NSString * fileName = [NSString stringWithFormat: @ "% @ / textfile.txt", document directory]; NSString * content = @ "test Copy here to save the content to the document directory [content content file: filename atom: no encoding: NSStringEncodingConversionAllowLossy error: zero];}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -