Closed kyuranger closed 1 year ago
Hi @kyuranger This problem depends on your user permission and access level when executing an application on OS the application can't achieve more access than the user.
Ensure that the folder structure under C:\Users\mywat\Downloads
is not hidden and that the user attempting to save has full write permissions on the folders and files. Usually, an administrator on the machine can do this inside Windows Explorer by right-mouse clicking on the Downloads
folder, selecting Properties > General
and setting the Read-only and Hidden attributes to unchecked.
To ensure your app could be ok, do the below test to ensure your user account has permission on that folder.
string downloadFilePath = @"C:\Users\mywat\Downloads\file.txt";
FileStream fs = new FileStream(downloadFilePath, FileMode.Create);
I just did this with a try&catch. However, it creates the file successfully without any errors.
I tried to downgrade the package to 2.4.1. Now it won't report the Access denied error any more.
Whereas, it still reports the errors in output as below and cannot download the file any: Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Requests.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Net.Requests.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll
I found out the problem.
My code should modify from this: Downloader.DownloadFileTaskAsync("https://dw11.uptodown.com/dwn/ssqNkZIxVNKMWHTLCmh2pYJTO12K3HDUaQD4NHAbLaRT-teJVu1w1WDFRKKith4-LwMTFwf7kVoltISnqld6dvah6_zBqnAAEBn5gx7mW7vufg91ZNiZzK6FkWB_23GE/YVwpUEj1_dLqJhSoSURvH-LxChYiwS1POc5feAMLW1Re4UuXFq8jBhNEg6-2m9ex7kvPdIqUwJMXpAzb5kakOwVvcOei77jtVF1d4VZnJa68L1o3aHtSrGavFELDBT-u/AtWSi9BdCBj8FWg2JmCrnTmRZWx1-9ei01iB_tGYEPkJT9_l8imxnwfd0DLbWuvmCyo5aGIrJdNXlOC8WWKipbgJ4CPxs7Y5j0Xk9PJoXLU=/windows-10-22h2-build-19045.iso", "C:\Users\mywat\Downloads");
To this: DirectoryInfo path = new DirectoryInfo("C:\Users\mywat\Downloads"); Downloader.DownloadFileTaskAsync("https://dw11.uptodown.com/dwn/ssqNkZIxVNKMWHTLCmh2pYJTO12K3HDUaQD4NHAbLaRT-teJVu1w1WDFRKKith4-LwMTFwf7kVoltISnqld6dvah6_zBqnAAEBn5gx7mW7vufg91ZNiZzK6FkWB_23GE/YVwpUEj1_dLqJhSoSURvH-LxChYiwS1POc5feAMLW1Re4UuXFq8jBhNEg6-2m9ex7kvPdIqUwJMXpAzb5kakOwVvcOei77jtVF1d4VZnJa68L1o3aHtSrGavFELDBT-u/AtWSi9BdCBj8FWg2JmCrnTmRZWx1-9ei01iB_tGYEPkJT9_l8imxnwfd0DLbWuvmCyo5aGIrJdNXlOC8WWKipbgJ4CPxs7Y5j0Xk9PJoXLU=/windows-10-22h2-build-19045.iso",path );
Now it works.
I guessed you were set the path instead of the full name. When you set the second parameter as a string then you must give a full file name. If you want to give the directory name so create a DirectoryInfo
.
I guessed you were set the path instead of the full name. When you set the second parameter as a string then you must give a full file name. If you want to give the directory name so create a
DirectoryInfo
.
Yes, that's exactly what I fault.
Hi, the nuget package I am using is 3.0.1 and the target framework is .net 7 of WPF.
Here is my code:
After the code ran, the output reports the error as below: Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Requests.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Net.Requests.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.WebException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll Exception thrown: 'System.UnauthorizedAccessException' in System.Private.CoreLib.dll
Soon, the try&catch report an error: Access to the path 'C:\Users\mywat\Downloads' is denied.
Even I change different path or different disk, the error still here.
What's wrong with it?