2017-02-10 6 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

설명서를 보았지만 코드를 작성할 수 있다면 더 낫습니다. –