![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Collections.Generic;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Linq;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Net;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Controls;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Documents;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Input;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Media;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Media.Animation;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.Windows.Shapes;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.IO.IsolatedStorage;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using System.IO;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
namespace Silverlight20.Data
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
public partial class IsolatedStorage : UserControl
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
public IsolatedStorage()
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
InitializeComponent();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 演示 IsolatedStorageFile
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
Demo();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 演示 IsolatedStorageSettings
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
Demo2();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// <summary>
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// 演示 IsolatedStorageFile
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// </summary>
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
void Demo()
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Isolated Storage - 独立存储。一个虚拟文件系统
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageFile - 操作 独立存储 的类
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageFile.GetUserStoreForSite() - 按站点获取用户的独立存储
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageFile.GetUserStoreForApplication() - 按应用程序获取用户的独立存储
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForSite())
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// DirectoryExists(path) - 指定的路径是否存在
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// CreateDirectory(path) - 创建指定的路径
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// FileExists(path) - 指定的文件是否存在
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// CreateFile(path) - 创建指定的文件
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// GetDirectoryNames() - 获取根目录下的目录名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// GetFileNames()() - 获取根目录下的文件名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// GetDirectoryNames(path) - 获取指定目录下的目录名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// GetFileNames(path) - 获取指定目录下的文件名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// OpenFile() - 打开指定的文件。具体参数参看文档
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// DeleteFile(path) - 删除指定的文件
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// DeleteDirectory(path) - 删除指定的目录(要求目录存在,且目录内无内容)
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Remove() - 关闭 IsolatedStorageFile 对象并移除独立存储内的全部内容
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 在根目录下创建指定的目录
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.DirectoryExists( "Directory01"))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.CreateDirectory( "Directory01");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.DirectoryExists( "Directory02"))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.CreateDirectory( "Directory02");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 创建指定的子目录
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string subDirectory01 = System.IO.Path.Combine( "Directory01", "SubDirectory01");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string subDirectory02 = System.IO.Path.Combine( "Directory01", "SubDirectory02");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.DirectoryExists(subDirectory01))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.CreateDirectory(subDirectory01);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.DirectoryExists(subDirectory02))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.CreateDirectory(subDirectory02);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 根目录下创建指定的文件
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.FileExists( "RootFile.txt"))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream isfs = isf.CreateFile( "RootFile01.txt");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isfs.Close();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 在指定的目录下创建指定的文件
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string file01 = System.IO.Path.Combine(subDirectory01, "File01.txt");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string file02 = System.IO.Path.Combine(subDirectory01, "File02.txt");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string file03 = System.IO.Path.Combine(subDirectory01, "File03.xml");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.FileExists(file01))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageFileStream - 独立存储内的文件流。继承自 FileStream
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream isfs = isf.CreateFile(file01);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isfs.Close();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.FileExists(file02))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream isfs = isf.CreateFile(file02);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isfs.Close();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (!isf.FileExists(file03))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream isfs = isf.CreateFile(file03);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isfs.Close();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += "根目录下的目录列表:\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 获取根目录下的目录名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
foreach ( string directoryName in isf.GetDirectoryNames())
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += directoryName + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += "根目录下的文件列表:\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 获取根目录下的文件名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
foreach ( string fileName in isf.GetFileNames())
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += fileName + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += "目录 Directory01 下的目录列表:\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 获取 Directory01 目录下的目录名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
foreach ( string directoryName in isf.GetDirectoryNames(subDirectory01))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += directoryName + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += "目录 Directory01/SubDirectory01 下的*.txt文件列表:\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 获取 Directory01/SubDirectory01 目录下的后缀名为 txt 的文件名数组
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
foreach ( string fileName in isf.GetFileNames(System.IO.Path.Combine(subDirectory01, "*.txt")))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += fileName + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (isf.FileExists(file01))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 在文件 file01 中写入内容
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream streamWrite = isf.OpenFile(file01, FileMode.Open, FileAccess.Write);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using (StreamWriter sw = new StreamWriter(streamWrite))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
sw.WriteLine( "我是:webabcd");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
sw.WriteLine( "我专注于asp.net, Silverlight");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += "文件 File01.txt 的内容:\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 读取文件 file01 中的内容
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageFileStream streamRead = isf.OpenFile(file01, FileMode.Open, FileAccess.Read);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using (StreamReader sr = new StreamReader(streamRead))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += sr.ReadToEnd();
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 删除文件 file01
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
if (isf.FileExists(file01))
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.DeleteFile(file01);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
try
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 删除目录 subDirectory01
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.DeleteDirectory(subDirectory01);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
catch (IsolatedStorageException ex)
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageException - 操作临时存储失败时抛出的异常
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 因为 subDirectory01 目录内还有文件,所以会抛异常
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg.Text += ex.Message;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// <summary>
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// 演示 IsolatedStorageSettings
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
/// </summary>
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
void Demo2()
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageSettings - 在独立存储中保存的 key-value 字典表
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageSettings.SiteSettings - 按站点保存的 key-value 字典表
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IsolatedStorageSettings.ApplicationSettings - 按应用程序保存的 key-value 字典表
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
IsolatedStorageSettings iss = IsolatedStorageSettings.ApplicationSettings;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Add(key, value) - 添加一对 key-value
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
iss.Add( "key", "value");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg2.Text += ( string)iss[ "key"] + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 修改指定的 key 的 value
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
iss[ "key"] = "value2";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg2.Text += ( string)iss[ "key"] + "\r\n";
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Remove(key) - 移除指定的 key
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Count - 字典表内的总的 key-value 数
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
iss.Remove( "key");
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
txtMsg2.Text += iss.Count;
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
private void increase_Click( object sender, RoutedEventArgs e)
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// 演示独立存储的配额的相关操作
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
{
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// Quota - 当前配额(KB)
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// IncreaseQuotaTo(newQuotaSize) - 增加到指定的配额
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
// AvailableFreeSpace - 当前的可用配额
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
isf.IncreaseQuotaTo(isf.Quota + 1 * 1024 * 1024);
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
System.Windows.Browser.HtmlPage.Window.Alert(
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
string.Format( "当前配额:{0};可用配额:{1}", isf.Quota, isf.AvailableFreeSpace));
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}
![](http://img.e-com-net.com/image/info3/78a0868db15f4e33ae8821aa4127a24d.gif)
}