2013-01-18 24 views
1

如何檢查在Phonegap框架中是否存在目錄和文件?
這是如何在PhoneGap的做
請幫我如何檢查Phonegap框架中是否存在目錄和文件?

+1

http://stackoverflow.com/questions/10294166/how-to-check-a-files-existence-in-phone-directory-with-phonegap –

+0

你好@amrit_neo這個好答案,但如果我想還檢查目錄,以便可能嗎? – Piyush

+1

http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#DirectoryEntry檢查getDirectory()方法 –

回答

1

您可以使用File Reader對象。

var reader = new FileReader(); 
var fileSource = <here is your file path> 

reader.onloadend = function(evt) { 

if(evt.target.result == null) { 
    // If you receive a null value the file doesn't exists 
} else { 
    // Otherwise the file exists 
}   
}; 

// We are going to check if the file exists 
reader.readAsDataURL(fileSource); 
+0

嗨@Hasintha這是用於文件檢查和目錄? – Piyush

+0

http://stackoverflow.com/questions/10294166/how-to-check-a-files-existence-in-phone-directory-with-phonegap – clintgh

相關問題