Information Technology Reference
In-Depth Information
IsolatedStorageFileStream myStream = new
IsolatedStorageFileStream ( "SavedStuff.txt" ,
FileMode .Create, iso);
StreamWriter wr = new StreamWriter (myStream);
// several wr.Write statements elided
wr.Close();
Reading is equally familiar to anyone who has used file I/O:
IsolatedStorageFile isoStore =
IsolatedStorageFile .GetUserStoreForDomain();
string [] files = isoStore.GetFileNames( "SavedStuff.txt" );
if (files.Length > 0 )
{
StreamReader reader = new StreamReader ( new
IsolatedStorageFileStream ( "SavedStuff.txt" ,
FileMode .Open, isoStore));
// Several reader.ReadLines( ) calls elided.
reader.Close();
}
Yo u c a n u s e i s o l a t e d s t o r a g e t o p e r s i s t r e a s o n a b l y s i z e d d a t a e l e m e n t s t h a t
enable partially trusted code to save and load information from a carefully
partitioned location on the local disk. The .NET environment defines lim-
its on the size of isolated storage for each application. This prevents mali-
cious code from consuming excessive disk space, rendering a system
unusable. Isolated storage is hidden from other programs and other users.
Therefore, it should not be used for deployment or configuration settings
that an administrator might need to manipulate. Even though it is hid-
den, however, isolated storage is not protected from unmanaged code or
from trusted users. Do not use isolated storage for high-value secrets unless
you apply additional encryption.
To c r e a t e a n a s s e m b l y t h a t c a n l i v e w i t h i n t h e p o s s i b l e s e c u r i t y r e s t r i c t i o n s
on the file system, isolate the creation of your storage streams. When your
assembly might be run from the Web or might be accessed by code run
from the Web, consider isolated storage.
Yo u m i g h t n e e d o t h e r p r o t e c t e d r e s o u r c e s a s w e l l . I n g e n e r a l , a c c e s s t o
those resources is an indication that your program needs to be fully
 
Search WWH ::




Custom Search