Webclient downloadfileasync无法正常工作 [英] Webclient downloadfileasync not working

查看:140
本文介绍了Webclient downloadfileasync无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,我想下载一个文件.

我正在使用System.Net;而且我有以下代码:

WebClient ww = new WebClient();
ww.DownloadFileAsync(
    new Uri("http://www.sinvise.net/tester/1.jpg"), 
    AppDomain.CurrentDomain.BaseDirectory + "\\1.jpg");

问题是,它没有下载文件,只是显示为0kb文件而没有下载,我不知道问题出在哪,有人可以帮忙吗?

解决方案

找到答案,我读到DownloadFile首先检查DNS,如果使用IP地址则它不进行检查并立即起作用./p>

尽管如此,感谢大家的帮助.

I got a WPF application and I want to download a file.

I'm using System.Net; and I have the following code:

WebClient ww = new WebClient();
ww.DownloadFileAsync(
    new Uri("http://www.sinvise.net/tester/1.jpg"), 
    AppDomain.CurrentDomain.BaseDirectory + "\\1.jpg");

The problem is, is that it doesn't download the file, it's just showing up as 0kb file and not downloading, I don't know what the problem is, can anyone help?

解决方案

Found the answer, I read that DownloadFile checks the DNS first before anything, if I use an IP address it doesn't do the check and immediately works.

Thanks for everyones help on this though.

这篇关于Webclient downloadfileasync无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆