IsolatedStorageScope.Assembly, null, null);
}
}
枚举存储区
您可以使用 IsolatedStorageFile 静态方法 GetEnumerator 枚举当前用户的所有独立存储区。GetEnumerator 取 IsolatedStorageScope 值并返回 IsolatedStorageFile 枚举数。User 是唯一受支持的 IsolatedStorageScope 值。要枚举存储区,您必须具有指定 IsolatedStorageContainment 值 AdministerIsolatedStorageByUser的 IsolatedStorageFilePermission。当使用 IsolatedStorageScope 值 User 进行调用时,GetEnumerator 返回为当前用户定义的 IsolatedStorageFiles 数组。
EnumeratingStores 示例
下面的代码示例获得按用户和程序集隔离的存储区并创建几个文件。调用 GetEnumerator 方法并将结果放入 IEnumerator。然后代码依次通过 IEnumerator,添加文件的大小,并将结果报告给控制台。实际枚举发生在私有 EnumerateTheStore 方法中,为了清楚起见,将该方法与代码的其他部分分开,放在文件的底部。
[C#]
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections;
public class EnumeratingStores{
public static int Main(){
// Get an isolated store for this assembly and put it into an
// IsolatedStorageFile object.
IsolatedStorageFile isoStore =IsolatedStorageFile.GetStore(IsolatedStorageScope.User
关键词:运用 .NET的IO(4) Paul_Ni(原作)