日期:2009-05-30 浏览次数:20448 次
[C#]
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections;
public class FindingExistingFilesAndDirectories{
// Retrieves an array of all directories in the store, and
// displays the results.
public static void Main(){
// This part of the code sets up a few directories and files in the
// store.
IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
isoStore.CreateDirectory("TopLevelDirectory");
isoStore.CreateDirectory("TopLevelDirectory/SecondLevel");
isoStore.CreateDirectory("AnotherTopLevelDirectory/InsideDirectory");
new IsolatedStorageFileStream("InTheRoot.txt", FileMode.Create, isoStore);
new IsolatedStorageFileStream("AnotherTopLevelDirectory/InsideDirectory/HereIAm.txt", FileMode.Create, isoStore);
// End of setup.
Console.WriteLine('\r');
Console.WriteLine("Here is a list of all directories in this isolated store:");
foreach(string directory in GetAllDirectories("*", isoStore)){
Console.WriteLine(directory);
}
Console.WriteLine('\r');
// Retrieve all the files in the directory by calling the GetFiles
// method.
Console.WriteLine("Here is a list of all the files in this isolated store:");
foreach(string file in GetAllFiles("*", isoStore)){
Console.WriteLine(file);
}
&n