HttpClientConnection.DownloadFile(String, Boolean) Método

Definição

Baixa os dados do recurso especificado pela propriedade ServerURL para um arquivo local.

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)

Parâmetros

fileName
String

O nome do arquivo local no qual os dados baixados são armazenados.

OverwriteDestination
Boolean

Um booliano que indica se um arquivo existente deve ser substituído, se encontrado. Um valor true substituirá o arquivo existente.

Exemplos

O exemplo de código a seguir mostra a criação de um HttpClientConnection, define os valores apropriados para o download e, em seguida, chama DownloadFile. O valor das propriedades requer substituição por valores válidos para seu aplicativo.

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  

Aplica-se a