争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

使用 .NET的IO(4) Paul_Ni(原作)

时间:2024/7/16作者:未知来源:争怎路由网人气:

IsolatedStorageScope.Assembly, null, null);
 

// This line of code calls a method at the bottom of the program
// that puts all the files in isoStore into an IEnumerator.

IEnumerator allFiles = EnumerateTheStore (isoStore);
long totalsize = 0;

// This code counts up the sizes of all the stores.

while(allFiles .MoveNext()){
 IsolatedStorageFile store = (IsolatedStorageFile)allFiles.Current;
 totalsize += (long)store.CurrentSize;
}

Console.WriteLine("The total size = "+totalsize);
return 0;
 }

 // This method returns an IEnucontaining all the files for a user.

 private static IEnumerator EnumerateTheStore(IsolatedStorageFile isoStore){

IEnumerator e = IsolatedStorageFile.GetEnumerator(IsolatedStorageScope.User);

return e;
 }
}
删除存储区
IsolatedStorageFile 提供了两种删除独立存储文件的方法:

实例方法 Remove 不取任何参数,删除调用它的存储区。该操作不需要任何权限。可以访问存储区的任何代码都可以删除该存储区中的任何数据或所有数据。
静态方法 Remove 采用 IsolatedStorageScope 值 User,并删除运行该代码的用户的所有存储区。该操作需要 IsolatedStorageContainment 值 AdministerIsolatedStorageByUser 的 IsolatedStorageFilePermission 权限。
DeletingStores 示例
下面的代码示例演示了静态和实例 Remove 方法的使用。类获得两个存储区,一个按用户和程序集隔离;另一个按用户、域和程序集隔离。通过调用 IsolatedStorageFile isoStore1 的 Remove 方法删除用户、域和程序集存储区。然后,通过调用静态方法 IsolatedStorageFile.Remove 删除该用户所有剩余的存储区。

[C#]
using System;
using System.IO.IsolatedStorage;

public class DeletingStores{

 public static void Main(){

// Get a new isolated store for this user, domain, and assembly.
// Put the store into an IsolatedStorageFile object.

IsolatedStorageFile isoStore1 =IsolatedStorageFile.GetStore(IsolatedStorageScope.User

关键词:运用 .NET的IO(4) Paul_Ni(原作)




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版