Chilkat  HOME  Android™  Classic ASP  C  C++  C#  Mono C#  .NET Core C#  C# UWP/WinRT  DataFlex  Delphi ActiveX  Delphi DLL  Visual FoxPro  Java  Lianja  MFC  Objective-C  Perl  PHP ActiveX  PHP Extension  PowerBuilder  PowerShell  PureBasic  CkPython  Chilkat2-Python  Ruby  SQL Server  Swift 2  Swift 3,4,5...  Tcl  Unicode C  Unicode C++  Visual Basic 6.0  VB.NET  VB.NET UWP/WinRT  VBScript  Xojo Plugin  Node.js  Excel  Go
 
      (C# UWP/WinRT) Co:Z SFTP Binary File Download (from z/OS IBM Mainframe)Demonstrates how to download a binary file, such as a .zip, from a Co:Z SFTP server on a z/OS IBM Mainframe. Note: This requires Chilkat v9.5.0.76 or greater. 
 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Chilkat.SFtp sftp = new Chilkat.SFtp(); // Connect to the SSH server. string hostname = "sftp.example.com"; int port = 22; bool success = await sftp.ConnectAsync(hostname,port); if (success != true) { Debug.WriteLine(sftp.LastErrorText); return; } success = await sftp.AuthenticatePwAsync("myLogin","myPassword"); if (success != true) { Debug.WriteLine(sftp.LastErrorText); return; } success = await sftp.InitializeSftpAsync(); if (success != true) { Debug.WriteLine(sftp.LastErrorText); return; } // To download a binary file from the Co:Z SFTP server, // we must switch to binary mode in the following unconventional way. // We pretend to fetch a directory listing for "/+mode=binary" // This has the effect of putting the server in binary mode for transfers. string handle = await sftp.OpenDirAsync("/+mode=binary"); if (sftp.LastMethodSuccess != true) { Debug.WriteLine(sftp.LastErrorText); return; } // Download the "directory listing" (but it's not actually a directory listing, and we'll just discard it.) Chilkat.SFtpDir dirListing = await sftp.ReadDirAsync(handle); if (sftp.LastMethodSuccess != true) { Debug.WriteLine(sftp.LastErrorText); return; } // Close the directory handle: success = await sftp.CloseHandleAsync(handle); if (success != true) { Debug.WriteLine(sftp.LastErrorText); return; } // Download the binary file: string localFilePath = "c:/temp/test.zip"; string remoteFilePath = "test.zip"; success = await sftp.DownloadFileByNameAsync(remoteFilePath,localFilePath); if (success != true) { Debug.WriteLine(sftp.LastErrorText); return; } Debug.WriteLine("Success.");  | 
  ||||
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.