Sync Download Of A File Dot Net (.Net)

Code Snippets 4 U
string DownloadSync(string url, string directory, string fileName)
        {
            var client = new WebClient();
            ServicePointManager.DefaultConnectionLimit = 2;
            string status = "started";
            Console.Write("Downloading - " + fileName);
            try
            {
                client.DownloadFile(new Uri(@url), @directory + @"\" + @fileName);
                status = "Successfully downloaded";
            }
            catch (WebException e)
            {
                status = e.Status.ToString();
            }
            Console.WriteLine("   >>>>>  Downloaded - ");
            return status;
        }

Leave a Reply

Your email address will not be published. Required fields are marked *

three + 3 =