Game Development Reference
In-Depth Information
is physically located on the hard drive. The physical location for isolated storage
varies for each operating system, so you just have to tell .NET framework to per-
sist data to isolated storage and it handles all the implementation details. Isolated
storage can also be specific to each assembly, or to each Windows user. Perhaps one
of the best features about isolated storage is that the application does not require
file system permissions. This makes it even easier for an application to run under
a least privilege account.
Isolated storage cannot be accessed by a different assembly than the one assigned to
do so. Isolated storage locations for assemblies are even isolated from each other with-
in the same process. The same security restriction applies to different Windows users.
It is important to know that isolated storage data is limited to 10 MB per each assembly. Just be
sure to efficiently manage the data placed in isolated storage and clean out cached data when it
is no longer needed.
Accessing Isolated Storage
The code to access isolated storage for this chapter also makes use of binary seri-
alization, generics, and the hashtable collection. The following code shows the
appropriate namespaces that are needed for this functionality.
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections;
using System.Deployment.Application;
using System.Runtime.Serialization.Formatters.Binary;
The first step for either the load or the save method is to retrieve the isolated stor-
age file that represents the top-level directory in the storage. This object can be
used to manipulate both files and directories. There are a couple different deploy-
ment situations that must be taken into consideration when working with isolat-
ed storage. The differences are later discussed in detail, but at this point you can be
aware that network deployed means that the application has been installed using
ClickOnce. The following code retrieves the appropriate isolated storage depend-
ing on the deployment situation.
private static IsolatedStorageFile OpenIsolatedStorage()
Search Nedrilad ::

Custom Search