Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Akarius wrote:

...but I still want it to continue the remaining uploads if an error occurs and I don't know how I can do this.

WinSCP .NET assembly does not support this. Though in many scenarios the Session.SynchronizeDirectories is good alternative that in principle supports "resuming".

I could give it a a future version...when I'll have the time :?

For the moment, it works great.
If it ain't broke, don't fix it!

Thanks for the insight.

I wonder if you could use separate threads? Or would the WinSCP instances step on each other?

(Just reaching ... apologies if the idea is ludicrous for some reason ) :lol:

I've added this line in the code and it solved the set times: No such file or directory error.
transferOptions.PreserveTimestamp = False

...but I still want it to continue the remaining uploads if an error occurs and I don't know how I can do this.

I could upload the file one by one but since I have to proceed about 400 files each hour, it'd be too time-consuming.

Any help welcome!

Here's a log file including the error.

I've replaced sensible parts with * for security reason.


Error during Session.PutFiles. Files remaining not uploaded.


This software is awesome! :)

I have a command line application in VB.NET that transfers a bunch of data files to a remote server once every hour (see code below).

My problem is if an error occurs during the Session.PutFiles function, the upload stops and all the remaining files aren't transfered to the server.

The error I got is:
scp: /apps/local/bdq/data/reception/chqc_02MC005_20130620_0815_ecshe.dat: set times: No such file or directory

How can I catch the error but resume the upload for the remaining files?

I'll leave for a long week-end soon but I'll check any reply when I'll get back Thuesday.
Thanks a lot!

Main part of code:
Public Sub TransfertSCP(scpAtt As scpAccess, xfertpath As String)

   Dim sessOpt As New SessionOptions
   With sessOpt
      .Protocol = Protocol.Scp
      .HostName = scpAtt.HostName
      .UserName = scpAtt.UserName
      .SshHostKeyFingerprint = scpAtt.SshHostKeyFingerprint
      .SshPrivateKeyPath = scpAtt.SshPrivateKeyPath
   End With
   Using Session As Session = New Session
         Session.ExecutablePath = System.AppDomain.CurrentDomain.BaseDirectory() & "ssh\WinSCPnet.exe"

         ' Connect
         ' Upload files
         Dim transferOptions As New TransferOptions
         transferOptions.TransferMode = TransferMode.Ascii

         writeLog(app.path_log, app.filename_log, _
                String.Format("Files in {0} to transfer: {1}", xfertpath, Directory.GetFiles(xfertpath).Count), LogLevel.INF)

         Dim transferResult As TransferOperationResult
         transferResult = Session.PutFiles(xfertpath, scpAtt.RemoteFolder, False, transferOptions)

         writeLog(app.path_log, app.filename_log, _
                   String.Format("Files in {0} transfered: {1}", xfertpath, transferResult.Transfers.Count), LogLevel.INF)

         For Each err As SessionRemoteException In transferResult.Failures
            writeLog(app.path_log, app.filename_log, String.Format("ERROR SCP Transfer failed: {0}", err.Message))

         ' Print transfert
         For Each transfer As TransferEventArgs In transferResult.Transfers
            Console.WriteLine("Upload of {0} succeeded", transfer.FileName)
            writeLog(app.path_log, app.filename_log, String.Format("SCP Transfer successful: {0}", transfer.FileName))
      Catch ex As Exception
         writeLog(app.path_log, app.filename_log, String.Format("ERROR SCP Transfet {0}", ex.Message))
      End Try
   End Using
End Sub