. Advertisement .
..3..
. Advertisement .
..4..
I am tired of fixing the problem: an exception occurred during a webclient request in the csharp; even if I get the reference from another forum, it still returns an error:
'An exception occurred during a WebClient request.
To identify the problem, I will show you the detail here:
new WebClient().DownloadFile("XXXX", checkingfolder.SelectedPath);
How do I do that? Could you support me in improving this problem?
The cause:
It looks like your directory to path doesn’t exist. When you don’t have directory, Web Client cannot find the Folder to locate the downloaded files. This is the reason you are getting the “an exception occurred during a webclient request” error.
Solution:
If we specify that is the case, we can reproduce it. A folder name rather than a file name the destination, as in your example. Instead, let’s provide a file name.
A small note: If we look at
InnerException
, it will tell us that the problem is related to the file path.This is what it means:
It will work successfully if we make it as a file below:
This error may occur when another process or class accesses the file you just downloaded