This is an old revision of the document!

WinSCP .NET Assembly Examples

Illustrative Examples

Example Description Languages
Overall example Create a session, upload a file and check/print results. C#, VB.NET, PowerShell, JScript, VBScript, VBA, Perl, SSIS
Session.GetFiles example Download file. C#, VB.NET, PowerShell, JScript, VBScript
Session.ListDirectory method example Retrieve and print contents of remote directory. C#, VB.NET, PowerShell, JScript, VBScript
Session.SynchronizeDirectories method and Session.FileTransferred event example Synchronize local and remote directories, handle Session.FileTransferred event to display synchronization progress. C#, VB.NET, PowerShell, JScript
Session.ExecuteCommand method example Execute a command on a remote side, download results. C#, VB.NET, PowerShell
Session.FileTransferProgress event example Display progress of file transfer. C#, VB.NET, PowerShell

Real-Life Examples

Example Languages
Downloading file to timestamped-filename PowerShell
Downloading the most recent file C#, PowerShell
Moving local files to different location after successful upload PowerShell
Deleting remote files after successful remote to local synchronization PowerShell
Listing files matching wildcard PowerShell
Recursively download directory tree with custom error handling C#, PowerShell
Search recursively for text in remote directory / Grep files over SFTP/FTP protocol PowerShell
Verify checksum of a remote file against a local file over SFTP/FTP protocol PowerShell
Locking files while uploading / Upload to temporary file name PowerShell
Uploading a list of files PowerShell
Find duplicate files in SFTP/FTP server PowerShell
Custom directory listing format (CSV) PowerShell
Automating transfer in parallel connections over SFTP/FTP protocol C#, PowerShell
Protecting credentials used for automation C#, PowerShell
Checking file existence and timestamp C#, VB.NET, PowerShell, JScript, VBScript
Downloading files from FTP/SFTP server only after “done” file is created PowerShell
Downloading all files from FTP/SFTP to the same local folder PowerShell
Pack files to ZIP archive and upload it PowerShell
Implementing SSH host key cache (known hosts) C#, PowerShell
Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure C#, PowerShell
Download remote file from a path stored in clipboard PowerShell
Watching for changes in SFTP/FTP server C#, PowerShell
Advanced files rename on SFTP/FTP server PowerShell
Keep local directory up to date (download changed files from remote SFTP/FTP server) PowerShell
Remember already downloaded files so they are not downloaded again PowerShell

Advertisement

Last modified: by martin