How to save a string into file (file.superlongextention
) in applicationdirectory
and get its real locationon Hard drive (like C:/files/...
)?
For security reason you can't write into the Application directory (for testing you can but it 's realy not recommended).
You can write into the Application Storage directory to store your application data.
To get the path of the file use nativePath.
import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
import mx.controls.Alert;
// get a file reference to the storage directory
var file:File=File.applicationStorageDirectory.resolvePath("myfile.withextension");
// create a file stream
var fs:FileStream=new FileStream();
// open the stream for writting
fs.open(file, FileMode.WRITE);
// write the string data down to the file
fs.writeUTFBytes("my string to save");
// ok close the file stream
fs.close();
// show the path to the file we have saved using Alert
Alert.show(file.nativePath);