Differences

This shows you the differences between the selected revisions of the page.

library 2021-09-23 library 2024-10-03 (current)
Line 1: Line 1:
====== WinSCP .NET Assembly and COM Library ====== ====== WinSCP .NET Assembly and COM Library ======
-The WinSCP .NET assembly ''winscpnet.dll'' is a .NET wrapper around WinSCP's [[scripting|scripting interface]] that allows your code to connect to a remote machine and manipulate remote files over SFTP, FTP, WebDAV, S3 and SCP sessions from .NET languages, such as [[#csharp|C#]], [[#vbnet|VB.NET]], and others, or from environments supporting .NET, such as [[library_powershell|PowerShell]], [[library_ssis|SQL Server Integration Services (SSIS)]], ASP.NET and Microsoft Azure WebSite.+The WinSCP .NET assembly ''winscpnet.dll'' is a .NET wrapper around WinSCP's [[scripting|scripting interface]] that allows your code to connect to a remote machine and manipulate remote files over SFTP, FTP, WebDAV, S3 and SCP sessions from .NET languages, such as [[#csharp|C#]], [[#vbnet|VB.NET]], and others, or from automation environments supporting .NET, such as [[library_powershell|PowerShell]], [[library_ssis|SQL Server Integration Services (SSIS)]] and Microsoft Azure WebSites and Functions.
The assembly is also exposed to COM, and as such it can be used from variety of other programming languages and development environments--e.g., [[library_com_wsh|WSH-hosted active scripting languages]] like JScript and VBScript, [[library_vb|Visual Basic for Applications (VBA)]], [[library_perl|Perl]], and Python. The assembly is also exposed to COM, and as such it can be used from variety of other programming languages and development environments--e.g., [[library_com_wsh|WSH-hosted active scripting languages]] like JScript and VBScript, [[library_vb|Visual Basic for Applications (VBA)]], [[library_perl|Perl]], and Python.
Line 14: Line 14:
The library is not a general purpose file transfer library. It particularly has a limited support for an interactive processing, and as such it is not well suited for use in GUI applications. The library is not a general purpose file transfer library. It particularly has a limited support for an interactive processing, and as such it is not well suited for use in GUI applications.
-For the same reason it is also difficult to use the assembly within a restricted environment like a web server, that limits or even restricts execution of external processes.+Because the assembly uses ''winscp.exe'' internally, it is also difficult (but not impossible) to use the assembly within a restricted environment like a ==web== server (e.g. with ASP.NET), that limits or even restricts execution of external processes.
===== Downloading and Installing the Assembly ===== ===== Downloading and Installing the Assembly =====
Line 87: Line 87:
                UserName = "user",                 UserName = "user",
                Password = "mypassword",                 Password = "mypassword",
-                SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...="+                SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."
            };             };
Line 142: Line 142:
                .UserName = "user"                 .UserName = "user"
                .Password = "mypassword"                 .Password = "mypassword"
-                .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...="+                .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."
            End With             End With
Line 186: Line 186:
See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]]. See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]].
-Option Explicit +==== [[vba]] VBA Example ==== 
-  +See [[library_vb#example|overall VBA example]].
-Sub Example() +
-  +
-    Dim mySession As New Session +
-     +
-    ' Enable custom error handling +
-    On Error Resume Next +
-     +
-    Upload mySession +
-     +
-    ' Query for errors +
-    If Err.Number <> 0 Then +
-        MsgBox "Error: " & Err.Description +
-  +
-        ' Clear the error +
-        Err.Clear +
-    End If +
-     +
-    ' Disconnect, clean up +
-    mySession.Dispose +
-     +
-    ' Restore default error handling +
-    On Error GoTo 0 +
-     +
-End Sub +
-Private Sub Upload(ByRef mySession As Session) +
-  +
-    ' Setup session options +
-    Dim mySessionOptions As New SessionOptions +
-    With mySessionOptions +
-        .Protocol = Protocol.sftp +
-        .HostName = &quot;ftp2-dhllink.dhl.com" +
-        .UserName = &quot;a2aomslowtier_sftp+
-       .Password = "PnxAPNKp8Tp45hXW" +
-        .SshHostKeyFingerprint = "ssh-rsa 2048 rUHNM1B9cQfUrB9aulY2VrfxtKZ4YRm6xrP5o5TDPc8=+
-         +
-    End With +
-     +
-    ' Connect +
-    mySession.Open mySessionOptions +
-     +
-    ' Upload files +
-    Dim myTransferOptions As New TransferOptions +
-    myTransferOptions.TransferMode = TransferMode_Binary +
-     +
-    Dim transferResult As TransferOperationResult +
-    Set transferResult = _ +
-        mySession.PutFiles("C:\Temp\*", &quot;/in/", False, myTransferOptions) +
-     +
-    ' Throw on any error +
-    transferResult.Check +
-     +
-    ' Display results +
-    Dim transfer As TransferEventArgs +
-    For Each transfer In transferResult.Transfers +
-        MsgBox "Upload of " & transfer.Filename & " succeeded" +
-    Application.InputBox ("OK") +
-     +
-    Next +
-     +
-End Sub +
==== [[perl]] Perl Example ==== ==== [[perl]] Perl Example ====

Last modified: by 165.225.113.32