![](/img/trans.png)
[英]DotNetZip System.UnauthorizedAccessException: Access to the path is denied
[英]System.UnauthorizedAccessException: Access to the path:PATH is denied
出于某种原因,Windows拒绝我的webclient下载。
它有权做任何事情,但它仍然被拒绝。 为什么?
码:
web.DownloadFile("super epic link", location);
错误:
System.Net.WebException: An exception occurred during a WebClient request. ---> System.UnauthorizedAccessException: Access to the path 'C:\Users\JANGAJ GAMES\source\repos\html executer\html updater\bin\Debug' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at html_updater.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\Users\JANGAJ GAMES\source\repos\html executer\html updater\Form1.cs:line 39
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
这是因为IIS无法访问该文件。 而是使用Path.GetDirectoryName(Application.ExecutablePath)
来访问Path.GetDirectoryName(Application.ExecutablePath)
的当前文件夹
var fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "download.txt");
web.DownloadFile("super epic link", fileName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.