2012-12-19 232 views
0

我遇到問題。我正在用AS3爲android創建一個應用程序,並且問題出現了,當我在我的android中安裝應用程序時,我應該創建的目錄不會顯示,也不會顯示該文件。AS3查找根目錄SDCard路徑並在目錄中搜索

var dirPath:File = File.applicationStorageDirectory.resolvePath("MUSIC/");      
var newFile:File = File.applicationStorageDirectory.resolvePath("songslist.xml"); 
if (!dirPath.exists) 
    { 
     dirPath.createDirectory(); 
     stream.open(newFile, FileMode.WRITE); 
     stream.close(); 
     trace("entra if"); 
    } 
if (!newFile.exists) 
    { 
     stream.open(newFile, FileMode.WRITE); 
     stream.close(); 
    } 

可能是我應該寫的問題,並isntall在SD卡中的應用程序?以及如何獲取稍後根sdcard用於搜索目錄中的所有現有* .mp3文件以添加到我的songslist.xml中

+0

請不要提出您的問題。這讓他們更難閱讀,這很煩人,而且被認爲是粗魯的。它也不會幫助你更快。謝謝。 :-) –

+0

如果有人希望我至少解決了它。如果(!newFile.exists) \t \t \t \t { \t \t \t \t \t stream.open(NEWFILE,FileMode.WRITE); \t \t \t \t \t stream.close(); \t \t \t \t} \t \t \t別的 \t \t \t \t { \t \t \t \t \t newFile.deleteFile(); \t \t \t \t \t stream.open(newFile,FileMode.WRITE); \t \t \t \t \t stream.close(); \t \t \t \t} –

回答

0

我至少解決了它。如果任何人有興趣或有同樣的問題。

var newFile:File = File.desktopDirectory.resolvePath("MusicPlayer/songslist.xml"); 
if (!newFile.exists) 
{ 
    stream.open(newFile, FileMode.WRITE); 
    stream.close(); 
} 
else 
{ 
    newFile.deleteFile(); 
    stream.open(newFile, FileMode.WRITE); 
    stream.close(); 
}