Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.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#,所以我有一个自动检查更新的函数,它使用XML检查更新 代码如下: foreach (XElement update in patchXml.Descendants("update")) { // Defines XElements, strings and ints if (serverPatch > localPatch) { // Using web

所以我有一个自动检查更新的函数,它使用XML检查更新

代码如下:

        foreach (XElement update in patchXml.Descendants("update"))
        {
            // Defines XElements, strings and ints

            if (serverPatch > localPatch)
            {
                // Using webclient downloadAsync, downloads ALL newest patches, not just one (which is what I don't want it to do)
            }
            else
            {
                // Continues to program
            }
        } 
然后DownloadFileCompleted处理文件并将其应用于需要更新的文件


我怎么能一次只下载一个文件?

不要使用异步版本的下载方法。@Matiascero它真的那么简单吗?是的。该文件将同步下载,阻止当前执行线程并阻止下载下一个文件,直到当前文件完成。谢谢,我将尝试此操作并在完成后立即报告!