2012-05-14 44 views

回答

3

的最佳方式將是簡單的:

var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,filename); 
if (file.exists()) { 
    file.deleteFile(); 
} 

完整的細節Titanium.Filesystem.File

1

刪除文件是這樣的簡單,

var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'delete_me.txt'); 
f.write('foo'); 
// make sure there's content there so we're sure the file exists 
// Before deleting, maybe we could confirm the file exists and is writable 
// but we don't really need to as deleteFile() would just return false if it failed 
if (f.exists() && f.writeable) { 
    var success = f.deleteFile(); 
    Ti.API.info((success == true) ? 'success' : 'fail'); // outputs 'success' 
} 

在文件系統中一個最好的材料在簡單:https://wiki.appcelerator.org/display/guides/Filesystem+Access+and+Storage#FilesystemAccessandStorage-Deletingfiles