2017-02-10 15 views
0

をexsist?アクションスクリプト3チェック現在のファイルとフォルダがコンパイルさ<strong>AIR</strong>実行可能なアプリケーションの</strong>を<strong>現在のパスを取得し、</strong>が同じ場所に存在し<strong>ファイル</strong>と<strong>フォルダを確認する方法

私はこのコードを使用しようとしたが、それは動作しません:

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

このコードのどの部分が間違っていますか? –

+1

「動作しません」と定義します。間違ったケースを追跡していますか?それとも、他のトレースが正常に動作している間にトレースしないのですか? – Organis

+0

問題を明確に定義し、努力と試行を提示し、失敗/結果を提示してください。だから私たちは何が問題であり、いくつかの解決策を提示する考えを持つことができます。 – coner

答えて

1

あなたのコードでほんの少しの変化。

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

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 
+0

私はドキュメンテーションを見ましたが、コードを書くことができればそれが良かったです。 –

関連する問題

 関連する問題