2012-07-31 70 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

回答