System.IO.File.WriteAllBytes时Asp.net Core System.UnauthorizedAccessException

问题描述 投票:-1回答:1

我在Asp.Net Core中获得了Access Exception。

System.UnauthorizedAccessException:'拒绝访问路径'C:**** \ source \ repos \ webcore \ webcore \ wwwroot'。

此异常由System.IO.File.WriteAllBytes生成

var webRoot = _hostingEnvironment.WebRootPath;

string hexString = System.Net.WebUtility.UrlEncode(reader.ReadToEnd());

System.IO.File.WriteAllBytes(webRoot, ConvertHexToBytes(hexString));

我试图在管理员模式下运行VS,我将网络服务添加到用户组,但它没有成功。你还有其他想法吗?

c# asp.net-core
1个回答
0
投票

我的坏,Path是一个目录。让我尴尬:

© www.soinside.com 2019 - 2024. All rights reserved.