C# download file from url Edit
this article contains code on how to download a file from a URL in C#. The file can be downloaded from a url using WebClient.DownloadFile method.
using (var client = new WebClient()) { client.DownloadFile("http://yourdomain.com/file/yourfilename.ext", "yourfilename.ext"); }
your application will throw an error if the account under which the application executes does not have permission to access the file.
check the code below, here I am using this code in asp .net MVC application to download the file to a particular folder.
using (var client = new WebClient()) { string sPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Files/"); client.DownloadFile("http://rigservbi.com/transocean/OpenPO/OpenPO_AIM_PROD.CSV", sPath @"OpenPO_AIM_PROD.CSV"); }
Check this article to read file from ftp server C# download file from ftp