Поделиться через


Метод HttpClientConnection.DownloadFile

Downloads data from the resource specified by ServerURL property to a local file.

Пространство имен:  Microsoft.SqlServer.Dts.Runtime
Сборка:  Microsoft.SqlServer.ManagedDTS (в Microsoft.SqlServer.ManagedDTS.dll)

Синтаксис

'Декларация
Public Sub DownloadFile ( _
    fileName As String, _
    OverwriteDestination As Boolean _
)
'Применение
Dim instance As HttpClientConnection 
Dim fileName As String 
Dim OverwriteDestination As Boolean

instance.DownloadFile(fileName, OverwriteDestination)
public void DownloadFile(
    string fileName,
    bool OverwriteDestination
)
public:
void DownloadFile(
    String^ fileName, 
    bool OverwriteDestination
)
member DownloadFile : 
        fileName:string * 
        OverwriteDestination:bool -> unit
public function DownloadFile(
    fileName : String, 
    OverwriteDestination : boolean
)

Параметры

  • fileName
    Тип: System.String
    The name of the local file into which the downloaded data is stored.
  • OverwriteDestination
    Тип: System.Boolean
    A Boolean that indicates whether to overwrite an existing file, if found. A value of true will overwrite the existing file.

Примеры

The following code example shows the creation of an HttpClientConnection, sets appropriate values for the download, then calls DownloadFile. The value of the properties requires replacement with values that are valid for your application.

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

См. также

Справочник

HttpClientConnection Класс

Пространство имен Microsoft.SqlServer.Dts.Runtime