簡體   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