Differences

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

2016-02-03 2016-02-03
redundant type specification (martin) no my prefix (martin)
Line 153: Line 153:
        Try         Try
            ' Setup session options             ' Setup session options
-            Dim mySessionOptions As New SessionOptions +            Dim sessionOptions As New SessionOptions 
-            With mySessionOptions+            With sessionOptions
                .Protocol = Protocol.Sftp                 .Protocol = Protocol.Sftp
                .HostName = "example.com"                 .HostName = "example.com"
Line 162: Line 162:
            End With             End With
-            Using mySession As New Session+            Using session As New Session
                ' Connect                 ' Connect
-                mySession.Open(mySessionOptions)+                session.Open(sessionOptions)
                Dim stamp As String = DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture)                 Dim stamp As String = DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture)
Line 174: Line 174:
                ' You can achieve the same using:                 ' You can achieve the same using:
-                ' mySession.SynchronizeDirectories( _+                ' session.SynchronizeDirectories( _
                '    SynchronizationMode.Local, localPath, remotePath, False, False, SynchronizationCriteria.Time, _                 '    SynchronizationMode.Local, localPath, remotePath, False, False, SynchronizationCriteria.Time, _
                '    New TransferOptions With { .FileMask = fileName }).Check                 '    New TransferOptions With { .FileMask = fileName }).Check
-                If mySession.FileExists(remotePath) Then+                If session.FileExists(remotePath) Then
                    Dim download As Boolean                     Dim download As Boolean
                    If Not File.Exists(localPath) Then                     If Not File.Exists(localPath) Then
Line 183: Line 183:
                        download = True                         download = True
                    Else                     Else
-                        Dim remoteWriteTime As DateTime = mySession.GetFileInfo(remotePath).LastWriteTime+                        Dim remoteWriteTime As DateTime = session.GetFileInfo(remotePath).LastWriteTime
                        Dim localWriteTime As DateTime = File.GetLastWriteTime(localPath)                         Dim localWriteTime As DateTime = File.GetLastWriteTime(localPath)
Line 203: Line 203:
                    If download Then                     If download Then
                        ' Download the file and throw on any error                         ' Download the file and throw on any error
-                        mySession.GetFiles(remotePath, localPath).Check()+                        session.GetFiles(remotePath, localPath).Check()
                        Console.WriteLine("Download to backup done.")                         Console.WriteLine("Download to backup done.")

Last modified: by martin