Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to download a file from a web url using windows application

Below is the code that I used for downloading the file.

WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.sample.com/downloads/test.tsv", @"C:\download\test.tsv");


I am unable to download the file. Below is the error message that I am getting.

Error Message:
Additional information: The underlying connection was closed: An unexpected error occurred on a send.


Please help me out with a sample code. It tried googling but no luck.

What I have tried:

WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.sample.com/downloads/test.tsv", @"C:\download\test.tsv");
Posted
Comments
Graeme_Grant 20-Sep-17 6:38am    
Look at the inner exception.
sacraj 20-Sep-17 8:56am    
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
Graeme_Grant 20-Sep-17 16:37pm    
This is saying that you need to authenticate/sign-in before you can access the file.
Richard MacCutchan 20-Sep-17 6:49am    
Check the network connection.
sacraj 20-Sep-17 8:56am    
I am able to download the same file via browser

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900