HttpClientConnection.DownloadFile(String, Boolean) 方法

定义

从属性 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  

适用于