Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- class FileFromInternet
- {
- static void Main()
- {
- Console.Write("Enter web address to download file from: ");
- string address = Console.ReadLine();
- Console.Write("Enter full path where to download and file name at the end: ");
- string file = Console.ReadLine();
- string fullAddress = address + "," + file;
- WebClient webClient = new WebClient();
- try
- {
- webClient.DownloadFile(fullAddress, file);
- Console.WriteLine("Download is finished!");
- }
- catch (ArgumentNullException)
- {
- Console.WriteLine("The address can not be null");
- }
- catch (NotSupportedException)
- {
- Console.WriteLine("This method does not support simultaneous downloads.");
- }
- catch (WebException)
- {
- Console.WriteLine("Wrong web addres or destination folder.");
- }
- finally
- {
- webClient.Dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement