Differences
This shows you the differences between the selected revisions of the page.
| library_session_fileexists 2016-03-31 | library_session_fileexists 2022-06-16 (current) | ||
| Line 8: | Line 8: | ||
| <code vbnet *> | <code vbnet *> | ||
| - | Public Function FileExists(ByVal path As String) As Boolean | + | Public Function FileExists(path As String) As Boolean |
| </code> | </code> | ||
| Line 25: | Line 25: | ||
| ===== [[example]] Examples ===== | ===== [[example]] Examples ===== | ||
| + | |||
| ==== [[csharp]] C# Example ==== | ==== [[csharp]] C# Example ==== | ||
| <code csharp> | <code csharp> | ||
| Line 43: | Line 44: | ||
| UserName = "user", | UserName = "user", | ||
| Password = "mypassword", | Password = "mypassword", | ||
| - | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| }; | }; | ||
| Line 91: | Line 92: | ||
| .UserName = "user" | .UserName = "user" | ||
| .Password = "mypassword" | .Password = "mypassword" | ||
| - | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| End With | End With | ||
| Line 136: | Line 137: | ||
| UserName = "user" | UserName = "user" | ||
| Password = "mypassword" | Password = "mypassword" | ||
| - | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| } | } | ||
| Line 150: | Line 151: | ||
| if ($session.FileExists($remotePath)) | if ($session.FileExists($remotePath)) | ||
| { | { | ||
| - | Write-Host ("File {0} exists" -f $remotePath) | + | Write-Host "File $remotePath exists" |
| # Now you can e.g. download file using session.GetFiles | # Now you can e.g. download file using session.GetFiles | ||
| Line 157: | Line 158: | ||
| else | else | ||
| { | { | ||
| - | Write-Host ("File {0} does not exist" -f $remotePath) | + | Write-Host "File $remotePath does not exist" |
| exit 1 | exit 1 | ||
| } | } | ||
| Line 167: | Line 168: | ||
| } | } | ||
| } | } | ||
| - | catch [Exception] | + | catch |
| { | { | ||
| - | Write-Host $_.Exception.Message | + | Write-Host "Error: $($_.Exception.Message)" |
| exit 2 | exit 2 | ||
| } | } | ||
| Line 190: | Line 191: | ||
| sessionOptions.UserName = "user"; | sessionOptions.UserName = "user"; | ||
| sessionOptions.Password = "mypassword"; | sessionOptions.Password = "mypassword"; | ||
| - | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"; | + | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."; |
| var session = WScript.CreateObject("WinSCP.Session"); | var session = WScript.CreateObject("WinSCP.Session"); | ||
| Line 253: | Line 254: | ||
| .UserName = "user" | .UserName = "user" | ||
| .Password = "mypassword" | .Password = "mypassword" | ||
| - | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
| End With | End With | ||
| Line 283: | Line 284: | ||
| ==== Real-Life Examples ==== | ==== Real-Life Examples ==== | ||
| - | * [[library_example_check_existence_timestamp|Checking file existence and timestamp]]; | + | * [[library_example_check_existence_timestamp|*]]; |
| - | * [[library_example_moves_files_keeping_directory_structure|Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure]]; | + | * [[library_example_moves_files_keeping_directory_structure|*]]. |