I'm pretty new to Isolated Storage and have run across a problem.
I'm serializing a PageSettings object and storing using Isolated Storage.
When trying to load the PageSettings I'm getting a FileNotFoundException.
It's weird.
Here is my functio to load the settings:
<code>
public PageSettings LoadBuildSnLabelPageSettings()
{
PageSettings pageSettings = null;
try
{
IsolatedStorageFile f = IsolatedStorageFile.GetStore(
IsolatedStorageScope.User |
IsolatedStorageScope.Assembly, null, null);
if
(f.GetFileNames(IsolatedStorageFileNames.BuildSnLa belPageSettings).Length >
0)
{
using (IsolatedStorageFileStream fs =
new
IsolatedStorageFileStream(IsolatedStorageFileNames .BuildSnLabelPageSettings,
FileMode.Open))
{
if (fs.CanRead)
{
BinaryFormatter formatter = new BinaryFormatter();
pageSettings = (PageSettings)formatter.Deserialize(fs);
}
}
}
}
catch (Exception e)
{
_logService.Log(LogType.Error, e.ToString());
}
return pageSettings;
}
</code>
'IsolatedStorageFileNames.BuildSnLabelPageSettings ' is a "constants class"
of mine that has the name of different files I store in Isolated Storage.
The file in this example is called; "BuildSnLabelPageSettings.xml"
The exception is thrown on the line:
"using (IsolatedStorageFileStream fs = new
IsolatedStorageFileStream(IsolatedStorageFileNames .BuildSnLabelPageSettings,
FileMode.Open))"
The exception text:
e = {"Could not find file
'BuildSnLabelPageSettings.xml'.":"BuildSnLabelPage Settings.xml"}
Now I'm confused by this message. Is it just formatting the message strange
or is it reporting that the missing file's name is:
"' BuildSnLabelPageSettings.xml'.":"BuildSnLabelPageS ettings.xml "
I don't know where it's getting that filename from.
Anyways, hopefully someone here has experienced a similar problem and might
know how to solve it.
Thanks for reading,
Steve Klett