System.IO.IsolatedStorage Namespace ()

Switch View :
ScriptFree
.NET Framework Class Library for Silverlight
System.IO.IsolatedStorage Namespace

The System.IO.IsolatedStorage namespace contains types for creating and using a virtual file system. Isolated storage provides safe client-side storage for partial-trust applications. In Silverlight, all I/O operations are restricted to isolated storage and do not use the file system of the operating system.

Classes

  Class Description
Public class IsolatedStorageException The exception that is thrown when an operation in isolated storage fails.
Public class IsolatedStorageFile Represents an isolated storage area containing files and directories.
Public class IsolatedStorageFileStream Exposes a file within isolated storage.
Public class IsolatedStorageSettings Provides a Dictionary<TKey, TValue> that stores key-value pairs in isolated storage.
Community Content

M Francis
Windows Phone 7: Enumerate Files
Windows Phone 7:
To enumerate files in isaolated storage:

public void EnumerateIsolatedStorageFiles()
{
try
{
// Get an isolated store for this applicaiton and put it into an
// IsolatedStorageFile object.
using (IsolatedStorageFile isoStore = 
IsolatedStorageFile.GetUserStoreForApplication())
{
// Create sub directories and create files 
// in them to test enumeration
isoStore.CreateDirectory("A");
IsolatedStorageFileStream streamA =
new IsolatedStorageFileStream(@"A\TestFileA.Txt", FileMode.Create, isoStore);
isoStore.CreateDirectory("B");
IsolatedStorageFileStream streamB = 
new IsolatedStorageFileStream(@"B\TestFileB.Txt", FileMode.Create, isoStore);
isoStore.CreateDirectory("C");
IsolatedStorageFileStream streamC = 
new IsolatedStorageFileStream(@"C\TestFileC.Txt", FileMode.Create, isoStore);
isoStore.CreateDirectory(@"C\1");
IsolatedStorageFileStream streamC1 = 
new IsolatedStorageFileStream(@"C\1\TestFileC1.Txt", FileMode.Create, isoStore);
isoStore.CreateDirectory(@"D\1\2\3\4\5");
IsolatedStorageFileStream streamD = 
new IsolatedStorageFileStream(@"D\1\2\3\4\5\TestFileD.Txt", FileMode.Create, isoStore);
streamA.Close();
streamB.Close();
streamC.Close();
streamC1.Close();
streamD.Close();
// There might be a small delay between when the above code
// executes and when the files are created in the store.
// Closing and opening the store in this example ensures that
// the common language runtime has finished creating the files.
} // using
using (IsolatedStorageFile isoStore = 
IsolatedStorageFile.GetUserStoreForApplication())
{
// List files in root
foreach (string file in isoStore.GetFileNames())
{
Debug.WriteLine(file);
}
// Recursively enumerate sub-directories and list contents
GetFiles(isoStore, @"\");
} // using
}
catch (IsolatedStorageException e)
{
Debug.WriteLine(e.Message);
}
}
// Recursively enumerate sub-directories
void GetFiles(IsolatedStorageFile isoStore, string directory)
{
string[] DirNames;
if (directory == @"\") 
DirNames = isoStore.GetDirectoryNames();
else
DirNames = isoStore.GetDirectoryNames(directory + @"\*");
foreach (string dir in DirNames)
{
string mDir = 
directory == @"\" ? directory + dir : directory + @"\" + dir;
foreach (string file in isoStore.GetFileNames(mDir + @"\*.*"))
{
Debug.WriteLine(mDir + @"\" + file);
}
GetFiles(isoStore, mDir);
}
}