Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 操作已超时_C# - Fatal编程技术网

C# 操作已超时

C# 操作已超时,c#,C#,我们删除了以下代码,这些代码在以编程方式下载文件时会导致超时: System.Net.WebClient Client = new System.Net.WebClient(); if (!File.Exists(fileName)) { Client.DownloadFile(downloadLink, fileName); HtFilesSuccessfullyDownloaded[fileName] = fileName; string SuccessfullyDo

我们删除了以下代码,这些代码在以编程方式下载文件时会导致超时:

System.Net.WebClient Client = new System.Net.WebClient();
if (!File.Exists(fileName))
{
    Client.DownloadFile(downloadLink, fileName);
    HtFilesSuccessfullyDownloaded[fileName] = fileName;
    string SuccessfullyDownloadedFiles = Path.Combine(dirName, "SuccessfullyDownloadedFiles.txt");
    File.AppendAllText(SuccessfullyDownloadedFiles, Environment.NewLine + fileName);
}
看起来,当文件很大时,调用DownloadFile方法时会出现超时错误。我们已在web.config中添加了以下标志,但它似乎没有帮助:

 <httpRuntime maxRequestLength="1048576" executionTimeout="3600"
/>


如果您有任何建议,请告诉我。

您正在将文件下载到服务器,并且
web.config
条目适用于从客户端上载的文件

检查这个问题以获得你需要的答案


出于好奇……在下载过程中,您将向用户展示什么?

您是否尝试过使用Fiddler查看到底发生了什么?它可能会给你提供更多的线索。坦率地说,这甚至可能是Web服务器的问题,而不是您的代码的问题。HTTPWebrequest还有一个可以设置的超时。你可以试试看



您正在下载到服务器。为什么要使用asp.net应用程序?