简体   繁体   English

C#GetFileAsync权限被拒绝

[英]C# GetFileAsync Permission Denied

In the C# app I am writing, I created a blank text file called "WriteLines.txt" in my Solution Explorer using the Add New Item feature. 在我编写的C#应用​​程序中,我使用“添加新项”功能在“解决方案资源管理器”中创建了一个空白文本文件“ WriteLines.txt”。

However, When I try to modify this text file and set its content equal to a string I named output using the following lines of code, I get the Permission Denied exception on the " FileIO.WriteLineAsync code (E_ACCESSDENIED) ": 但是,当我尝试修改此文本文件并将其内容设置为使用以下代码行命名为输出的字符串时,在“ FileIO.WriteLineAsync code (E_ACCESSDENIED) ”上得到“权限被拒绝”异常:

var file1 = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("WriteLines.txt");
await FileIO.WriteTextAsync(file1, output);

The "WriteLines.txt" file is not read-only, I already checked its properties. “ WriteLines.txt”文件不是只读的,我已经检查了它的属性。

Does anyone spot the problem? 有人发现问题了吗?

The other option is to make sure that you run VS as an administrator. 另一个选择是确保以管理员身份运行VS。 So when you run VS right click the exe and select run as administrator. 因此,在运行VS时,右键单击exe,然后选择以管理员身份运行。 That should elevate permissions. 那应该提升权限。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打开文件(C#)时拒绝Process.start()权限 - Process.start() permission denied when opening file (C#) zip创建时拒绝C#SharePoint 2010权限 - C# SharePoint 2010 Permission denied on zip creation C#中的Rebex SFTP错误:PutFile上的权限被拒绝 - Rebex SFTP error in C#: Permission denied on PutFile C# Renci.SshNet.Common.SshAuthenticationException:“权限被拒绝(密码)。” - C# Renci.SshNet.Common.SshAuthenticationException: 'Permission denied (password).' C#/ C ++-如何获取路径太长或权限被拒绝的目录的大小? - C#/C++ - how to get size of directory where path is too long, or permission denied? UWP C# 和 Windows 运行时组件 C++ 打开文件时出现权限被拒绝错误 - UWP C# and Windows Runtime Component C++ Permission Denied error when opening file 为什么通过C#AWS开发工具包将文件上传到s3,却显示拒绝权限错误? - Why is uploading a file to s3 via the C# AWS SDK giving a permission denied error? 使用C#下载文件并将权限设置为“所有人”,但我看到访问被拒绝 - Download File in C# and set permission to Everyone but I see Access Denied C# Google 地理编码:即使按照所需的步骤操作,权限也会不断被拒绝 - C# Google Geocoding: Constantly Getting Permission Denied Even When following the Steps Required C#Raspberry pi Linux串行端口权限甚至以root身份被拒绝 - C# Raspberry pi Linux serial port permission denied even as root
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM