Reputation: 247
How to get current path of a compiled AIR executable application and check a file and folder exist in same location?
I tried to use this code but it doesn't work:
var File1:File = File.applicationDirectory.resolvePath('APPAR-NC.exe');
if (File1.exists)
{
trace("The file exists.");
}
else
{
trace("The file does not exists.")
};
Upvotes: 0
Views: 438
Reputation: 729
Just a small change in your code.
var File1:File = File.applicationDirectory.resolvePath("APPAR-NC.exe");
if (File1.exists)
{
if(File1.isDirectory)
trace("The folder exists.");
else
trace("The file exists.");
}
else
{
trace("The file does not exists.")
};
Upvotes: 1
Reputation: 7316
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html
// The folder where your app is installed to.
File.applicationDirectory:File
// The same result as above.
new File("app://")
// The same folder as a system path string.
File.applicationDirectory.nativePath:String
// Returns true if file/folder, represented by the File object, exists.
File.exists:Boolean
// Returns true if the path, represented by the File object, is a folder rather than a file.
File.isDirectory:Boolean
Upvotes: 2