Game Development Reference
In-Depth Information
{
settings = (Hashtable)formatter.Deserialize(loadStream);
}
catch (Exception)
{
// Quietly handle this error
}
}
if (settings == null)
{
settings = new Hashtable();
}
settings[key] = setting;
using (Stream writeStream = new IsolatedStorageFileStream(fileName,
FileMode.Create, storage))
{
formatter.Serialize(writeStream, settings);
}
}
catch (Exception)
{
// Quietly handle this error
}
}
The load routine for the isolated storage interface is just as easy as the save. First,
we check to make sure the settings file exists in isolated storage, and we open it as
a stream if possible. The data from the stream is then sent into BinaryFormatter ,
and data is deserialized into a hashtable containing the settings. The appropriate
value referenced by the supplied key is then returned. The following code shows
the load routine for the isolated storage interface.
public static TYPE ReadSetting<KEY, TYPE>(string fileName, KEY key)
{
try
{
IsolatedStorageFile storage = OpenIsolatedStorage();
string[] fileMatches = storage.GetFileNames(fileName);
Search Nedrilad ::




Custom Search