2013-03-07 132 views
0

我想這個目錄 我用這個方法來創建我的isoalted存儲目錄和子目錄目錄中的獨立存儲的Windows Phone

private void create_directory(string directoryName) 
{ 
    try 
    { 
     IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); 
     if (!myIsolatedStorage.DirectoryExists(directoryName)) 
     { 
      myIsolatedStorage.CreateDirectory(directoryName); 

      myIsolatedStorage.CreateDirectory(directoryName+"/Books"); 
      myIsolatedStorage.CreateDirectory(directoryName + "/EpubBooks"); 

     } 
    } 
    catch (Exception ex) 
    { 
     // handle the exception 
    } 
} 

但是當我打開獨立存儲資源管理器,我只手錶目錄下的兩個子目錄不會被創建

+0

是否引發異常? – 2013-03-07 16:54:52

+1

你沒有真正處理這個異常,你只是把它從你自己身上隱藏起來。嘗試啓用CLR異常並在調試器中運行代碼以查看會發生什麼。 – 2013-03-08 07:28:31

回答

0

嘗試使用代碼迭代獨立存儲。創建您的子目錄:

private void TestDir(string directoryName) 
    { 
     var list = new List<string>(); 
     try 
     { 
      var myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); 
      if (myIsolatedStorage.DirectoryExists(directoryName)) 
      { 
       var path = string.Format("{0}\\*", directoryName); 
       list = myIsolatedStorage.GetDirectoryNames(path).ToList(); 
      } 
     } 
     catch 
     { 

     } 
    } 

貌似有a bug in Isolated Storage Explorer(見第一註釋)。

+0

謝謝,我會嘗試 – hamza437 2013-03-11 09:45:46

相關問題