var fileName = "c:\\sounds\\demo.mp3";
if (File.exists(fileName))
{
var f = new File(fileName);
trace(f.size);
trace(f.shortName);
}
Furthermore, the File object and the Folder object can also be used to copy, move or delete files or folders. For example, copy a file
var file = new File("c:\\sounds\\demo.mp3");
file.copy("d:\\demo.mp3");
The FileStream object is used to read data from a file or write data to a file. It can not only read or write strings, but read or write binary data. For example, the get method is used to read a byte from a file, while the readLine method can read a line of string from a file. The following Action script code for Flash 8 shows how to write a XML object to a file
import SWFKit.*;
var xml = new XML;
// XML operations
...
...
// Save a XML file
var fs = new FileStream("c:\\my.xml", "w");
fs.writeLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
fs.write(xml.toString());
fs.close();
fs.Release();