private string ReadFile(string fileName) //读文件
{
string text;
using (IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isolatedStorageFile.FileExists(fileName))
{
isolatedStorageFile.DeleteFile(fileName);
}
using (IsolatedStorageFileStream isolatedStorageFileStream = isolatedStorageFile.OpenFile(fileName, FileMode.Open))
{
using (StreamReader streamReader = new StreamReader(isolatedStorageFileStream))
{
text = streamReader.ReadToEnd();
}
}
}
return text;
}
public void writeFile(String fileName, String text) // 写文件
{
using (IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication())
{
lock(_readLock)
{
using (IsolatedStorageFileStream isolatedStorageFileStream = isolatedStorageFile.CreateFile(fileName))
{
using (StreamWriter streamWriter = new StreamWriter(isolatedStorageFileStream))
{
streamWriter.Write(text);
}
isolatedStorageFileStream.Close();
isolatedStorageFileStream.Dispose();
}
}
}
}
WP8用户独立存储空间中文件的创建和读取
最新推荐文章于 2017-11-06 02:28:00 发布