Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# \bin\x86\Debug\AppX\Assets的访问问题\_C#_File_Uwp_Access Denied - Fatal编程技术网

C# \bin\x86\Debug\AppX\Assets的访问问题\

C# \bin\x86\Debug\AppX\Assets的访问问题\,c#,file,uwp,access-denied,C#,File,Uwp,Access Denied,情况如下: 我想把我得到的图片放到我的资产中的一个文件中。 我想获取包含以下内容的文件夹: StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(Directory.GetCurrentDirectory()); 并在其中创建一个文件,其中包含: File.Create(folder.Path + @"\" + "Assets" + @"\" + stora

情况如下: 我想把我得到的图片放到我的资产中的一个文件中。 我想获取包含以下内容的文件夹:

StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(Directory.GetCurrentDirectory());
并在其中创建一个文件,其中包含:

File.Create(folder.Path + @"\" + "Assets" + @"\" + storageItem.DisplayName + storageItem.FileType);
但当我尝试创建文件时,它会向我抛出System.UnauthorizedAccessException。我需要一个永久的修复程序,因为其他用户(一些没有管理权限)将需要使用我正在编写的程序


提前感谢

您的当前目录可能已设置为需要管理员权限的位置。您可以更改当前目录:

下面看起来是一个关于您应该在哪里存储东西的相当可靠的概述,并且有大量的代码示例


您当前的目录可能设置为需要管理员权限的位置。您可以更改当前目录:

下面看起来是一个关于您应该在哪里存储东西的相当可靠的概述,并且有大量的代码示例


这是正确的,因为您无法在已安装目录中更改或创建某些内容。此目录可用的唯一选项是读取存在于其中的文件

如果您想在应用程序本地或临时目录中保留一些文件,则可以使用


AppliationData.Currunt.LocalFolder/TemproryFolder等保存文件

这是正确的,因为您无法在已安装目录中更改或创建某些内容。此目录可用的唯一选项是读取存在于其中的文件

如果您想在应用程序本地或临时目录中保留一些文件,则可以使用


appliationdata.Currunt.LocalFolder/TemproryFolder等来保存您的文件

非常感谢,遗憾的是,概述中显示的“简单”方法应该总是可以访问,但它返回了一个
System.IO.FileNotFoundException
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
)这让我很困惑,因为这些特殊文件夹应该存在?@JL_Funk Environment.GetFolderPath不应该引发文件未找到异常。你能发布完整的代码吗?奇怪的是,现在已经没有了。但它不可能是在注释其他内容,因为抛出错误的是这一行:
var test=Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)非常感谢,遗憾的是,概述中显示的“简单”方法应该总是可以访问,但它返回了一个
System.IO.FileNotFoundException
环境.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
),这让我很困惑,因为这些特殊文件夹应该存在?@JL_Funk Environment.GetFolderPath不应该引发文件未找到异常。你能发布完整的代码吗?奇怪的是,现在已经没有了。但它不可能是在注释其他内容,因为抛出错误的是这一行:
var test=Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)