Win10S导致Certified W10 App向APPDATA写入数据失败

Win10S causes Certified W10 App to fail writing data to APPDATA

我们的 win10app 早些时候在 Win10Store 中被接受没有问题,但最近新的 Win10S 要求似乎导致 certification/testing 阶段失败,即使 appx 包一年没有更改。应用程序似乎未通过认证,因为应用程序发出文件写入失败/访问被拒绝。

我们的 destop 桥接应用程序只是将数据文件存储到 %appdata% 文件夹,写入用户自己的数据文件并在 Win10S 和 Windows 10 桌面上工作的正确路径是什么?

UWP 应用应该将本地数据写入本地应用文件夹:

%localappdata%\Packages\[app-package-name]\LocalState

通常通过 StorageFolder object returned by the ApplicationData.LocalFolder 属性.

访问
using Windows.Storage;
using System.Threading.Tasks;

// Get the app's local folder.
StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

// Create a new file in the current folder.
// Raise an exception if the file already exists.
string desiredName = "test.txt";
StorageFile newFile = await localFolder.CreateFileAsync(desiredName, CreationCollisionOption.FailIfExists);

您可以在桌面桥应用中使用相同的代码来访问应用的本地文件夹。