C# 4.0 删除Windows Phone 8上IsolatedStorage中的文件
我想删除一个由我的Windows Phone 8生成的文件。这是我的代码,但我遇到了一个异常:无法删除文件。但我不知道为什么。有什么想法吗C# 4.0 删除Windows Phone 8上IsolatedStorage中的文件,c#-4.0,windows-phone-8,isolatedstorage,C# 4.0,Windows Phone 8,Isolatedstorage,我想删除一个由我的Windows Phone 8生成的文件。这是我的代码,但我遇到了一个异常:无法删除文件。但我不知道为什么。有什么想法吗 if (myIsoStore.FileExists(fileName)) { myIsoStore.DeleteFile(fileName); } 这是Windows Phone 8 emulator中的一个错误,有时应用程序会丢失其在隔离存储中的文件权限 您必须从emulator中删除该应用程序,然后从visual studio中重新实现该应用程序,
if (myIsoStore.FileExists(fileName))
{
myIsoStore.DeleteFile(fileName);
}
这是Windows Phone 8 emulator中的一个错误,有时应用程序会丢失其在隔离存储中的文件权限
您必须从emulator中删除该应用程序,然后从visual studio中重新实现该应用程序,然后重试。文件是否仍处于打开状态?取决于您首先打开文件的方式-您的代码摘录不包括该部分。我使用的是StreamWriter:StreamWriter writeFile=new StreamWriter(new IsolatedStorageFileStream)(fileName,FileMode.CreateNew,myIsoStore));然后我写了一些东西并调用:writeFile.Flush();writeFile.Close();这对我来说很有用:
使用(var store=IsolatedStorageFile.GetUserStoreForApplication()){using(var f=newstreamwriter(new-IsolatedStorageFileStream(“foo.bar”,FileMode.CreateNew,store)){();f.Close();如果(store.FileExists(“foo.bar”){store.DeleteFile(“foo.bar”);}}}}}
-所以问题一定在别处。好吧。你的代码也对我有用。我有关于错误的更多信息:不允许对IsolatedStorageFileStream执行操作。第一次它也会对我的代码起作用,但如果我再次直接运行它,我会遇到此错误。