views:

26

answers:

2

is it possible to create a plain text file with AS3 or AIR?

example: i would like to create a plain text file named "MyTextFile.txt", have it contain text that reads "This is my text file." and save it to my desktop.

another option would be to have the file already exist in a directory, so i would only have to rewrite its contents - assuming that would be easier.

all of which should happen as a background process, without any save dialoge panel appearing.

+1  A: 

http://insideria.com/2008/03/beginning-air-accessing-the-fi-1.html

PatrickS
why was this answer down voted? it leads to a link with the correct answer.
TheDarkInI1978
i have no idea... i think they should leave a comment actually and explain why, but some people prefer to move in the shadows :)
PatrickS
I've observed some dislike of paste-a-link-and-press-submit answers in various places on StackOverflow. I think some of it stems from the fact that the ongoing reliability of an external link is less suspect than that of StackOverflow and could eventually become inaccessible for future people searching for a similar answer. That said, this was a fairly straightforward solution so I'm not sure why there would be any fuss.
Tegeril
PatrickS
+3  A: 
var file:File = File.desktopDirectory.resolvePath("MyTextFile.txt");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes("This is my text file.");
stream.close();
Claus Wahlers