繁体   English   中英

C#WP8文件消失

[英]C# WP8 file disappearing

我将创建文件保存在文件夹中,并向其中写入一些数据,如下所示:

        if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\BinarySettings"))
            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\BinarySettings");

        string settingFilePath = Directory.GetCurrentDirectory() + "\\BinarySettings\\" + setting_Name + ".bindat";
        FileStream binaryFileStream = new FileStream(settingFilePath, FileMode.Create);//If the setting already exists overwrite it otherwise create it
        BinaryWriter binaryWriter = new BinaryWriter(binaryFileStream);

        binaryWriter.Write(setting_Bytes);
        binaryWriter.Flush();

        //Dispose of the streams after we have finished using them
        binaryWriter.Dispose();
        binaryFileStream.Dispose();

        Debug.WriteLine(File.Exists(settingFilePath));

这似乎很好用,因为此后从应用程序中任何位置对文件使用File.Exists都返回true。

奇怪的是,当我的应用程序再次启动并且我想从文件中加载数据时,它突然消失了。 在文件上尝试File.Exists突然返回false。

你们有没有发生过这种情况,什么原因可能导致这种奇怪的行为?

好的,问题是我实际上是在重新安装该应用程序,而不是重新启动它。 要重新启动它,您必须从Windows Phone而不是Viusal Studion进行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM