独立存储区是位于硬盘上的一个分区。可以确保让其他应用程序无法查看你的文件.
using System.IO.IsolatedStorage;
IsolatedStorageFile isoStore=IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly|IsolatedStorageScope.User,null,null);
string fn=isoStore.GetFileNames(“a.txt“);
if(fn==null)
{
StreamWriter sw=new StreamWriter(IsolatedStorageFileStream(“a.txt“),FileMode.CreateNew,isoStore);
sw.write(“hello“);
}
else
{
StreamReader sr=IsolatedStorageFileStream(“a.txt“),FileMode.Open,isoStore);
string s=sr.ReadLine();
}
using System.IO.IsolatedStorage;
IsolatedStorageFile isoStore=IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly|IsolatedStorageScope.User,null,null);
string fn=isoStore.GetFileNames(“a.txt“);
if(fn==null)
{
StreamWriter sw=new StreamWriter(IsolatedStorageFileStream(“a.txt“),FileMode.CreateNew,isoStore);
sw.write(“hello“);
}
else
{
StreamReader sr=IsolatedStorageFileStream(“a.txt“),FileMode.Open,isoStore);
string s=sr.ReadLine();
}
博客介绍独立存储区是硬盘上的分区,可防止其他应用查看文件。还给出了使用 C# 操作独立存储区的代码示例,包括获取存储区、检查文件是否存在、创建新文件写入内容以及打开文件读取内容等操作。
6446

被折叠的 条评论
为什么被折叠?



