2012-07-31 69 views
1

我創建了一個名爲「MyFolder」的目錄並在那裏寫了一些文本文件。現在,我想刪除該目錄,我使用下面的代碼:從隔離的存儲窗口刪除目錄windows phone 7

public void DeleteDirectory(string directoryName) 
     { 
      try 
      { 
       using (IsolatedStorageFile currentIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) 
       { 
        if (!string.IsNullOrEmpty(directoryName) && currentIsolatedStorage.DirectoryExists(directoryName)) 
        { 
         currentIsolatedStorage.DeleteDirectory(directoryName); 
         textBox1.Text = "deleted"; 
        } 
       } 
      } 
      catch (Exception ex) 
      { 
       // do something with exception 
      } 
     } 

DeleteDirectory("MyFolder") 
DeleteDirectory("IsolatedStore\\MyFolder") 

試過但它並沒有刪除該目錄。任何想法解決這個問題?

+0

您是否首先刪除了它中的所有內容?我不確定這是必需的......但它可能是? – 2012-07-31 22:01:58

+0

我第一次嘗試刪除文件,但結果相同。不知道這是什麼問題。 – MKS 2012-07-31 22:03:48

+0

http://stackoverflow.com/questions/6858050/deleting-isolated-storage-directories-in-windows-phone-7 我希望它能幫助你 – alikhil 2014-09-05 17:35:12

回答