我想写一个字符串的IsolatedStorageFile,但我得到一个IsolatedStorageException,在异常的链接,这是一个:定义未发现时,试图写入IsolatedStorageFile
http://www.microsoft.com/getsilverlight/DllResourceIDs/Default.aspx?Version=4.0.50829.0&File=mscorlib.dll&Key=IsolatedStorage_Operation_ISFS
它声明无法找到'resource ID'的定义。我不知道为什么会发生这种异常,这里是我的代码:
private void writeListToStorage(List<PlanningItemModel> items)
{
IsolatedStorageFile myIsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
if(myIsolatedStorageFile.FileExists("Zomerparkfeesten\\" + filePath))
{
IsolatedStorageFileStream iStream = myIsolatedStorageFile.OpenFile("Zomerparkfeesten\\" + filePath, FileMode.Open, FileAccess.Write);
string json = Converter.convertListOfItemsToJson(items);
StreamWriter writeFile = new StreamWriter(iStream);
try
{
writeFile.WriteLine(json);
writeFile.Close();
iStream.Close();
}
catch (IOException)
{
writeFile.Close();
iStream.Close();
}
}
else
{
myIsolatedStorageFile.CreateFile("Zomerparkfeesten\\" + filePath);
this.writeListToStorage(items);
}
}
任何想法?
你有文件夹创建Zomerparkfeesten?它在哪一行中断? –
是的,只要我尝试在myIsolatedStorageFile上执行操作,该文件夹就会中断。我试过OpenFile和DeletFile,它每次都抛出异常。 –
您是否尝试过以下语法:http://stackoverflow.com/questions/12625910/getting-operation-not-permitted-on-isolatedstoragefilestream-saving-jpg(var stream = new IsolatedStorageFileStream(“folder \\”+ fileName,FileMode .Create,FileAccess.Write,myIsolatedStorage)) –