C#WinForm网络文件下载问题
具体代码如下:publicvoidDownload(stringURL,stringDir){WebClientclient=newWebClient();stringf...
具体代码如下:
public void Download(string URL, string Dir)
{
WebClient client = new WebClient();
string fileName = URL.Substring(URL.LastIndexOf("/") + 1); //被下载的文件名
string Path = Dir + fileName; //另存为的绝对路径+文件名
try
{
WebRequest myre = WebRequest.Create(URL);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message,"Error");
}
try
{
client.DownloadFile(URL, Path);
}
catch(Exception exp)
{
MessageBox.Show(exp.Message,"Error");
}
}
private void button1_Click(object sender, EventArgs e)
{ this.Download("http://www.blzwow.cn/mp3/slfzl.wma", @"F:\");
}
本人想下载"slfzl.wma"这个文件到本机F盘,自己测试了,想了N久,老是报远程服务器返回404(未找到),不理解具体哪错了..还请诸位路过的朋友帮忙看看.. 展开
public void Download(string URL, string Dir)
{
WebClient client = new WebClient();
string fileName = URL.Substring(URL.LastIndexOf("/") + 1); //被下载的文件名
string Path = Dir + fileName; //另存为的绝对路径+文件名
try
{
WebRequest myre = WebRequest.Create(URL);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message,"Error");
}
try
{
client.DownloadFile(URL, Path);
}
catch(Exception exp)
{
MessageBox.Show(exp.Message,"Error");
}
}
private void button1_Click(object sender, EventArgs e)
{ this.Download("http://www.blzwow.cn/mp3/slfzl.wma", @"F:\");
}
本人想下载"slfzl.wma"这个文件到本机F盘,自己测试了,想了N久,老是报远程服务器返回404(未找到),不理解具体哪错了..还请诸位路过的朋友帮忙看看.. 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询