file=IsolatedStorageFile.GetUserStoreForApplication()) { file.CreateDirectory file=IsolatedStorageFile.GetUserStoreForApplication()) { if (file.DirectoryExists file = IsolatedStorageFile.GetUserStoreForApplication()) { file.DeleteDirectory file = IsolatedStorageFile.GetUserStoreForApplication()) { if (file.FileExists file = IsolatedStorageFile.GetUserStoreForApplication()) { file.DeleteFile
下面简单的说下用法: 一、创建、存储: IsolatedStorageFile _isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream new StreamWriter(stream); writer.WriteLine("abcdefg"); writer.Close(); stream.Close(); 二、读取文件: IsolatedStorageFile _isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream StreamReader(stream); string data = reader.ReadToEnd(); reader.Close(); stream.Close(); 三、取得本独立区的文件列表: IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForDomain(); string[] filenames = store.GetFileNames("*
System.IO; 下面的代码展示了,如何在存储区创建目录/文件,以及如何写入文件,读取文件 1try { using (var store = IsolatedStorageFile.GetUserStoreForApplication try { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) try { using (var store = IsolatedStorageFile.GetUserStoreForApplication())
第一是通过库中的键/值对,叫做IsolatedStorageSettings(独立设置存储),第二是通过创建真实的文件和目录,叫做IsolatedStorageFile(独立文件存储)。 settings.Save(); 独立文件存储: 命名空间为:System.IO.IsolatedStorage;主要涉及System.IO.IsolatedStorage.IsolatedStorageFile 实际上,IsolatedStorage.IsolatedStorageFile类是 FileStream类 的一个子类。 public partial class MainPage : PhoneApplicationPage { //为程序获取一个虚拟的本地存储 IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); // 构造函数 public MainPage
Silverlight beta 2 的配置有一个重大变化就是对DRM 和Application Storage的配置 Application storage的默认大小是1M,可以通过代码修改,通过使用IsolatedStorageFile IsolatedStorageFile 类抽象了isolated storage的虚拟文件系统 . 你创建一个 IsolatedStorageFile 类的实例, 你可以使用它对文件或文件夹进行列举或管理.同样你还可以使用该类的 IsolatedStorageFileStream 对象来管理文件内容. 一个属于它的虚拟文件系统. .NET Framework version 2.0中的文件夹节构和隐藏架构同样在 .NET Framework for Silverlight中也用到了. var store = IsolatedStorageFile.GetUserStoreForApplication 代码如下: using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { // Request 5MB more
➔ 为保存一个新的文件,SaveContent方法首先调用IsolatedStorageFile. GetUserStoreForApplication。 ➔ GetContent 和 DeleteContent与SaveContent类似,利用了IsolatedStorageFile中的另外三个方法:FileExists, OpenFile, 和 DeleteFile ➔ 在管理文件时,我们有可能使用IsolatedStorageFile.GetFileNames方法来枚举并显示文件,但该方法存在一些问题,比如: ➔ 隔离存储空间的API并没有包含发现创建/修改文件日期的方法
用 IsolatedStorageFile 类。创建目录,文件,操作之。适合操作复杂数据或需要保存大量数据。 2. 用 IsolatedStorageSettings 类。
System.IO.IsolatedStorage命名空间中的类,这些类允许你的程序在特定用户的目录下将数据写入文件而不需要直接访问硬盘驱动器的权限: // 创建当前用户的独立存储 using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly()) { // 创建一个文件夹 store.CreateDirectory