2012-01-23 48 views

回答

9

使用GetFileNames方法。如果你只是想在IsolatedStorage根的所有文件的名稱,你可以

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) 
{ 
    string[] fileNames = store.GetFileNames(); 
} 

如果你想其他目錄裏的文件的名稱也一樣,你可以使用GetDirectoryNames方法來獲取所有的目錄名檢索根級別所有目錄的名稱。

GetFileNamesGetDirectoryNames也有重載的方法,它們採用搜索模式字符串並返回與模式匹配的所有文件/目錄的名稱。

因此,爲了得到一些目錄中的文件名,你可以

string searchPattern = directory + "\\*"; 
string[] fileNames = store.GetFileNames(searchPattern); 

這會給你存儲在directory目錄中的所有文件的名稱。

GetDirectoryNameshttp://msdn.microsoft.com/en-us/library/cc190673.aspx

GetFileNameshttp://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.getfilenames%28v=vs.95%29.aspx

相關問題