为什么我不能在XAML Project的Assets文件夹中写? [英] Why I can't write in Assets folder from XAML Project?
问题描述
我从资产中读取了一个xml文件。现在我想替换修改xml文件,但是当我想在xml文件中抛出异常时:
mscorlib中出现类型'System.UnauthorizedAccessException'的异常。 dll但未在用户代码中处理
其他信息:访问被拒绝。 (来自HRESULT的异常:0x80070005(E_ACCESSDENIED))
我可以在C:\ Users \ Servgiu \ Document中编写xml文件,但我想写xml来自项目的Assets文件夹中的文件。
I read a xml file from assets. Now I want to replace modify xml file, but when I want to wirte in xml file throwing exception:
An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I can write xml file in C:\Users\Sergiu\Documents, but I want to write xml file in Assets folder from project.
private async void CreateFILE(string file_name)
{
folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
sampleFile = await folder.CreateFileAsync(file_name, CreationCollisionOption.OpenIfExists);
}
private async void WriteFILE()
{
await Windows.Storage.FileIO.WriteTextAsync(sampleFile, xml_file);
//here throw exception
// xml_file is xml file contain
string xml_file = @"<?xml version=""1.0"" encoding=""utf-8"" ?>\n<Players>\n";
//...
xml_file+="</Players>";
}
推荐答案
这篇关于为什么我不能在XAML Project的Assets文件夹中写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!