Problem with writing to file

Hi,
I’m trying to save my file but even though my code works on corona simulator, it doesnt work when i test it on my ipad (iOS5.1)

my code :

local fullpath = system.pathForFile(fname, system.DocumentDirectory)
local file = io.open(fullpath, “w”)
print(“Try to write file @”,fullpath)
file:write(str)
file:close()

yet I always get this error :
main2_1121(10459) deny file-write-data /private/var/mobile/Applications/A17F4570-2312-441E-A4C7-EBA06860AABD/main2_1121.app/heroinit.xml

I’m using system.DocumentsDirectory just like what the tutorial says.
Anybody have the same problem as I am?

Thanks [import]uid: 76697 topic_id: 33207 reply_id: 333207[/import]

Well two things pop out. In your code you use system.DocumentDirectory and it should be system.Document s Directory. You have it right in your text below but not in your code.

Also, we can’t see what “fname” is. Is it a valid file name? is it not nil? What is str? What is the output of your print? [import]uid: 19626 topic_id: 33207 reply_id: 131932[/import]

ugh, you’re right… it was that “s” typo that caused it :slight_smile:
problem solved! Thanks for pointing that out! [import]uid: 76697 topic_id: 33207 reply_id: 132019[/import]

Well two things pop out. In your code you use system.DocumentDirectory and it should be system.Document s Directory. You have it right in your text below but not in your code.

Also, we can’t see what “fname” is. Is it a valid file name? is it not nil? What is str? What is the output of your print? [import]uid: 19626 topic_id: 33207 reply_id: 131932[/import]

ugh, you’re right… it was that “s” typo that caused it :slight_smile:
problem solved! Thanks for pointing that out! [import]uid: 76697 topic_id: 33207 reply_id: 132019[/import]