简体   繁体   中英

How to download a csv file from local folder in .net windows form application?

i need a help regarding download a sample file from local machine .could anyone please help me .

i tried below code ,

 string value = " ~/DE_V04/DE_V04/WindowsFormsApp1/Files/sample.csv";
 WebClient webClient = new WebClient();
 Uri url = new Uri(value);
 webClient.DownloadFileAsync(url, "~/sample.csv");

It seems as you just want to copy a file from one directory (which you have access to) to another directory (which you also have access to)? If so, there is no need for web requests. You could simply use

File.Copy(string sourceFileName, string destFileName) 

See documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM