我正在尝试从https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tar下载一个文件,以便使用the客户端保存到我的d:\驱动器。在类、结构或接口成员声明中,紧跟在"Client.DownloadFile“之后,我收到错误标记”(“)。
这是我第一次使用C#!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project1
{
class Class1
{
WebClient Client = new WebClient ();
Client.DownloadFile("https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tar", @"d:\epm.tar");
}
}发布于 2013-02-01 10:53:12
您需要将您的代码放入一个方法中:
namespace Project1
{
class Class1
{
public void DownloadIt()
{
WebClient Client = new WebClient ();
Client.DownloadFile("https://webgis.dme.qld.gov.au/webgis/webqmin/shapes/epm.tar", @"d:\epm.tar");
}
}
}然后,要使用它,您只需从控制台应用程序或winform应用程序调用该方法:
Class1 c = new Class1();
c.DownloadIt();https://stackoverflow.com/questions/14638939
复制相似问题