apache-flex ActionScripts 3检查当前文件和文件夹是否存在

ego6inou  于 2022-11-01  发布在  Apache
关注(0)|答案(2)|浏览(123)

如何获取已编译的AIR可执行应用程序的当前路径,并检查文件文件夹是否存在于同一位置?
我尝试使用此代码,但它不起作用:

var File1:File = File.applicationDirectory.resolvePath('APPAR-NC.exe');
if (File1.exists) 
{
    trace("The file exists.");
} 
else 
{
    trace("The file does not exists.")
};
2jcobegt

2jcobegt1#

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
jdgnovmf

jdgnovmf2#

只是代码中的一个小改动。

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

相关问题