保存按钮的代码如下:
private void btnSave_Click(object sender, RoutedEventArgs e)
{
string fileContent = this.txtContents.Text;
using (var storage = IsolatedStorageFile.GetUserStoreForApplication())
{
string filePath = System.IO.Path.Combine(@"C:\Users\v-yanjxu\Documents\Visual Studio 2013\Projects", this.txtFileName.Text);
IsolatedStorageFileStream stream = storage.OpenFile(filePath, FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(stream);
sw.Write(fileContent);
sw.Close();
stream.Close();
}
GetStorageData();
}
原本filePath=“File1.txt”;,这样保存是没有问题的,可是我要是把filePath改成filePath=System.IO.Path.Combine(@"C:\Users\v-yanjxu\Documents\Visual Studio 2013\Projects", this.txtFileName.Text);时,就会报“Operation not permitted on IsolatedStorageFileStream.”的异常。难道IsolatedStorageFile保存文件时不能指定路径么?