Uwp 如何授权对应用程序路径的访问?

Uwp 如何授权对应用程序路径的访问?,uwp,Uwp,我想在我的UWP应用程序中创建一个文件mytest.txt,但我总是遇到异常 对路径的UnauthorizedAccessException访问被拒绝 当我打电话时: string destinationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "mytest.txt"); FileStream fs = File.Create(d

我想在我的UWP应用程序中创建一个文件
mytest.txt
,但我总是遇到异常

对路径的UnauthorizedAccessException访问被拒绝

当我打电话时:

string destinationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "mytest.txt");
FileStream fs = File.Create(destinationPath);
我也尝试了
System.Environment.SpecialFolder.MyDocuments
,得到了相同的异常。我还在Visual Studio中调试我的应用程序,该应用程序是以管理员身份运行的


注意:这实际上是一个带有Xamarin.Forms的UWP应用程序,但我认为这与此无关。

使用以下代码可以在UWP中创建文件:

// Create sample file; replace if exists.
Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
storageFolder.CreateFileAsync("mytest.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);
文件: