save file example?

Hi, I’m trying to save some data to a plain text file in the iphone documents directory. Does anyone have an example of how to do this?

I don’t want to use the xmlSettings addon as I need the output to be in text file format. I’ve also tried some straight c++ as in this forum: http://forum.openframeworks.cc/t/how-do-i-save-to-a-file/3749/0 with no luck.

Any advice?

Thanks.

solved…

// create or open a file
string filename = “myfile.txt”;
File pFile = fopen((ofxiPhoneGetDocumentsDirectory() + filename).c_str(),“w”);

// add some lines of text
string line = “saving some data \n”;
fputs (line.c_str(),pFile);

// save file
fclose (pFile);

if you are in 007 also:

  
ofFile file(ofxiPhoneGetDocumentsDirectory() +"filename.txt",ofFile::WriteOnly);  
file << "saving some data";  
file.close();