基础操作语法
using System.IO.IsolatedStorage;
using System.IO;
void CreateDir(string dirName)
{
IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication();
storeFile.CreateDirectory(dirName);
}
void SaveFile(string savePath, string content)
{
IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream sf = storeFile.CreateFile(savePath);
using (StreamWriter sw = new StreamWriter(sf))
{
sw.WriteLine(content);
}
sf.Close();
}
void LoadFile(string readPath)
{
string content = string.Empty;
using (IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication())
{
if (storeFile.FileExists(readPath))
{
StreamReader sr =
new StreamReader(storeFile.OpenFile
(readPath, FileMode.Open, FileAccess.Read));
content = sr.ReadToEnd();
}
}
}
void DeleteFile(string path)
{
using (IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication())
{
storeFile.DeleteFile(path);
}
}
void DeleteDir(string dirPath)
{
using (IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication())
{
storeFile.DeleteDirectory(dirPath);
}
}
void LoadDirs()
{
using (IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication())
{
var itemSource = storeFile.GetDirectoryNames("*");
}
}
名值对方式存储读取
这种方式就很像Cookie了
string ReadSettings(string key)
{
IsolatedStorageSettings settings =
IsolatedStorageSettings.ApplicationSettings;
return settings[key].ToString();
}
void SaveSettings(string key, string value)
{
IsolatedStorageSettings settings =
IsolatedStorageSettings.ApplicationSettings;
settings.Add(key, value);
settings.Save();
}
void ClearSettings()
{
IsolatedStorageSettings settings =
IsolatedStorageSettings.ApplicationSettings;
settings.Clear();
}
独立存储的文件与名值对分别有两个示例,可以在目录地址链接下载代码阅读。
独立存储的空间大小
独立存储默认的空间上限是1M,可以通过代码设置让这个上限加大。代码如下
//使1用?应|用?程ì序ò存?储¢创′建¨对?象ó
using (IsolatedStorageFile storeFile =
IsolatedStorageFile.GetUserStoreForApplication())
{
//获?取?旧é空?间?大ó小?
long oldSize = storeFile.AvailableFreeSpace;
//定¨义?新?增?空?间?大ó小?
long newSize = 2097152;
if (oldSize < newSize)
{
//分?配?新?的?存?储¢空?间?
storeFile.IncreaseQuotaTo(newSize);
}
}
客户可以通过邮件Silverlight 控件选择Silverlight配置中 ->应用程序存储选项卡 中查看本地有存储了那些Silverlight应用存储信息。
引用地址:http://terryfeng.iteye.com/blog/595578
分享到:
相关推荐
WP7 Isolated Storage Explorer
window phone 8 Backup Isolated Storage To SkyDrive
2.记住密码,使用ISolatedStorage独立存储区,加载登录窗体 时,先查找独立存储区有无信息,若有且记住密码标志为"1", 则直接将用户名和密码写入输入框。 【登录成功后再根据 记住密码 的勾选情况重新写入记住...
14、Silverlight(16) - 2.0数据之独立存储(Isolated Storage) 15、Silverlight(17) - 2.0数据之详解DataGrid, 详解ListBox 16、Silverlight(18) - 2.0视频之详解MediaElement, 开发一个简易版的全功能播放器 17、...
在WebBrowser控件中包含来自IsolatedStorage的静态JS / CSS /图像文件
IsolatedStorageDemo 源代码
Consuming, transforming, and displaying content in your Silverlight web application through XML, LINQ-based data access, and isolated storage Building custom controls for your Silverlight project ...
Silverlight SPY是一款共享软件,该软件可以自动...同时,可以分解项目中的样式和UI,以及Isolated Storege展示给开发人员。我们在地址栏输入Silverlight.NET地址,即可得到,双击任何一个资源,在View窗口即可查看。
Silverlight中独立存储功能展示 1 获取存储目录 2 读写存储目录中的文件 3 清除存储目录 4 增加存储目录的空间容量
1、四大缓存方式,在Caching Application Block中,主要提供以下四种保存缓存数据的途径,分别是:内存存储(默认)、独立存储(Isolated Storage)、数据库存储(DataBase Cache Storage)和自定义存储(Custom ...
当Silverlight中没有BinaryFormatter时,如何将二进制数据序列化到Silverlight客户端中的IsolatedStorage? 为什么不使用sharpSerializer? -用于.NET和Silverlight的开源XML和二进制序列化器
Visual Studio 2013 Shell (Isolated)
isolated-vm
data storage and retrieval, integration with cloud services, adding media and location-based services, and working with Silverlight and Expression Blend. Learn to use sensors such as the camera, GPS,...
将文件复制到隔离存储中,以便您可以使用IsoStoreSpy下载它们。 安装 通过PC上的此链接获取已编译文件的存档文件: https://github.com/tandasat/CopyFiles/releases/latest 然后,使用“应用程序部署”工具部署...
8.6 Using Isolated Storage; 8.7 Enabling Elevated Trusted Mode; 8.8 Debugging Out of Browser Applications; 8.9 Interoperating with COM; 8.10 Using Notification Windows; 8.11 Key Points; Chapter 9: ...
IsolatedStorageSettings用法案例源码,源码IsolatedStorageSettings 用法之 程序...而本次所讲到的是在后台代码中利用 IsolatedStorageSettings 独立存储中实现 详细说明:http://wp.662p.com/thread-8019-1-1.html