【问题标题】:UWP Storage file is deleted on close even though I did not. How can I prevent it?UWP Storage file is deleted on close even though I did not. How can I prevent it?
【发布时间】:2022-12-26 11:38:24
【问题描述】:

I am developing XboxGameBar UWP app. UWP app cannot write a file at random location so I did as the microsoft doc said here.

Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Storage.StorageFile jsonFile = storageFolder.GetFileAsync("settings.json").AsTask().Result;
FileIO.WriteTextAsync(jsonFile, JsonConvert.SerializeObject(settingsList)).AsTask();

I checked the file is written as it is intended in app data storage folder. but when I saw the file the icon has a small padlock icon on it and it is deleted on app close. I wrote some json text to save app settings but it's gone and always do fresh start.

What I tested is that I deployed this app to another computer and i checked the file is not deleted on app close and has no padlock icon on it. it only happens on specific computers. Why is that? and how can I prevent it?

【问题讨论】:

  • Computers without a TPM module cannot locally encrypt the file, i.e. no lock. On persistence, check your parameters.

标签: c# uwp


【解决方案1】:

The solution was a certification issue of UWP app. UWP app must need to use verified certification even if it's sideloading. and temporary certification cannot be copied to another computer. without it you cannot write files. I resolved this issue by creating a dev certification on microsoft store

【讨论】:

    猜你喜欢
    • 2022-12-02
    • 2022-12-28
    • 2012-06-19
    • 2022-11-09
    • 2022-12-02
    • 2022-12-01
    • 2022-12-27
    • 2023-01-31
    • 2022-12-26
    相关资源
    最近更新 更多