Search code examples
actionscript-3apache-flexairanimate-cc

ActionScripts 3 check current file and folder exsist


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.")
};

Solution

  • 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.")
            };