I'm trying to write a string to an IsolatedStorageFile, but I'm getting an IsolatedStorageException, the link in the exception is this one:
http://www.microsoft.com/getsilverlight/DllResourceIDs/Default.aspx?Version=4.0.50829.0&File=mscorlib.dll&Key=IsolatedStorage_Operation_ISFS
And it states that the definition of 'resource ID' could not be found. I have no idea why this exception occurs, here's my code:
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);
}
}
Any ideas?
No, that's not what it says. Odd problem, might have something to do with you speaking Dutch instead of English. Looks like they fumbled the Dutch localization of this particular exception. When I visit that URL from the USA, I get:
Which of course makes a lot more sense, given the code snippet. I can't get you a lot more help beyond that, basic issue is that your program doesn't have write access to isolated storage. You'll need to give it access.
One nasty failure mode that's hard to diagnose, this code will always blow up with "Operation not permitted" when you pass an empty string for "filePath". That will make the code try to write a file that has the same name as an existing directory, that's never permitted.