HttpClientConnection.DownloadFile(String, Boolean) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将数据从 ServerURL 属性所指定的资源下载到本地文件。
public:
void DownloadFile(System::String ^ fileName, bool OverwriteDestination);
public void DownloadFile (string fileName, bool OverwriteDestination);
member this.DownloadFile : string * bool -> unit
Public Sub DownloadFile (fileName As String, OverwriteDestination As Boolean)
参数
- fileName
- String
存储下载数据的本地文件的名称。
- OverwriteDestination
- Boolean
一个布尔值,指示是否覆盖现有文件(如果找到)。 值为 true 将覆盖现有文件。
示例
下面的代码示例演示如何创建一个 HttpClientConnection,为下载设置适当的值,然后调用 DownloadFile。 属性的值需要使用对应用程序有效的值进行替换。
const string svcName = "Test_WebService";
string wsdlFile = Directory.GetCurrentDirectory() + @"\WebSvceTask_wsdl.wsdl";
//create HTTP connection
ConnectionManager httpConn = pkg.Connections.Add("HTTP");
HttpClientConnection clientConn = new HttpClientConnection(httpConn.AcquireConnection(null));
clientConn.UseProxy = true;
clientConn.ProxyURL = @"http://yourproxy";
clientConn.BypassProxyOnLocal = true;
clientConn.ServerURL = yourURL;
TaskHost th = (TaskHost)pkg.Executables.Add ("STOCK:WebServiceTask");
WebServiceTask task = (WebServiceTask)th.InnerObject ;
task.Connection = httpConn.Name;
task.ServiceName = svcName;
task.OutputType = DTSOutputType.Variable;
task.OutputLocation = "output";
clientConn.DownloadFile(wsdlFile, false);
task.WsdlFile = wsdlFile;
const String svcName = "Test_WebService"
Dim wsdlFile As String = Directory.GetCurrentDirectory() + "\WebSvceTask_wsdl.wsdl"
'create HTTP connection
Dim httpConn As ConnectionManager = pkg.Connections.Add("HTTP")
Dim clientConn As HttpClientConnection = New HttpClientConnection(httpConn.AcquireConnection(Nothing))
clientConn.UseProxy = True
clientConn.ProxyURL = "http://yourproxy"
clientConn.BypassProxyOnLocal = True
clientConn.ServerURL = yourURL
Dim th As TaskHost = CType(pkg.Executables.Add("STOCK:WebServiceTask"), TaskHost)
Dim task As WebServiceTask = CType(th.InnerObject, WebServiceTask)
task.Connection = httpConn.Name
task.ServiceName = svcName
task.OutputType = DTSOutputType.Variable
task.OutputLocation = "output"
clientConn.DownloadFile(wsdlFile, False)
task.WsdlFile = wsdlFile