Tag: 大文件

如何以编程方式下载C#中的大文件

我需要以编程方式下载大文件,然后再进行处理。 最好的方法是什么? 由于文件很大,我想要特定的时间等待,以便我可以强行退出。 我知道WebClient.DownloadFile()。 但似乎没有办法特定等待一段时间才能强行退出。 try { WebClient client = new WebClient(); Uri uri = new Uri(inputFileUrl); client.DownloadFile(uri, outputFile); } catch (Exception ex) { throw; } 另一种方法是使用命令行实用程序(wget)下载文件并使用ProcessStartInfo触发命令并使用Process’WellForExit(int ms)强制退出。 ProcessStartInfo startInfo = new ProcessStartInfo(); //set startInfo object try { using (Process exeProcess = Process.Start(startInfo)) { //wait for time specified exeProcess.WaitForExit(1000 * 60 * 60);//wait till 1m […]