Windows Phone 8.0 上写入后文件未修改

After writing, the file is not modified on Windows Phone 8.0

在执行此脚本期间未检测到任何错误,但文件未被修改。 在看作品,写的奇怪没有。

我的写作脚本:

private void firstLaunch(){
    try { 
        StreamWriter outfile = new StreamWriter("Path/something.txt");
        outfile.WriteLine("somethingElse");
        outfile.Close();
    }
    catch (IOException ex){
        MessageBox.Show(ex.Message);
    }
}

该文件已经存在并且已经包含在 visual studio 的项目中。此刻它完全是空的。

你能帮帮我吗?

你可以这样使用:

var res = App.GetResourceStream(new Uri("test.txt", UriKind.Relative));
var txt = new StreamReader(res.Stream).ReadToEnd();

只需确保文件的“生成操作”设置为“内容”即可。 如果文件为空,我建议使用 IsolatedStorage 在您的应用程序文件夹中创建一个。这样您就可以使用 IsoStoreSpy 检查文件的内容。