Winscp archive files after uploading

spider1269spider1269 Member Posts: 77
I'm wondering how everyone is archiving their files with Winscp after uploading them to a SFTP site. I have everything working except I'm archiving the entire contents of a folder after the files in the folder are uploaded. The issue is the folder is actively having files inserted and I may archive a file before it gets uploaded.

Answers

  • ara3nara3n Member Posts: 9,257
    archive each file after you have uploaded it.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • spider1269spider1269 Member Posts: 77
    I'm not sure how to do that in Winscp. Every function seems to be folder driven.
  • vaprogvaprog Member Posts: 1,150
    spider1269 wrote: »
    I'm not sure how to do that in Winscp. Every function seems to be folder driven.

    Certainly not. I use
        PROCEDURE SendFile(SourceFileName: Text;DestinationFileName: Text;Overwrite: Boolean);
        VAR
          transferOptions: DotNet "'WinSCPnet, Version=1.7.0.9963, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf'.WinSCP.TransferOptions";
          transferMode: DotNet "'WinSCPnet, Version=1.7.0.9963, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf'.WinSCP.TransferMode";
          transferOperationResult: DotNet "'WinSCPnet, Version=1.7.0.9963, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf'.WinSCP.TransferOperationResult";
          overwriteMode: DotNet "'WinSCPnet, Version=1.7.0.9963, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf'.WinSCP.OverwriteMode";
        BEGIN
          transferOptions := transferOptions.TransferOptions;
          transferOptions.PreserveTimestamp := TRUE;
          transferOptions.TransferMode := transferMode.Binary;
          transferOptions.OverwriteMode := overwriteMode.Overwrite;
          // Overwrite is default. There is no option to throw an error. This code assumes, the existence of a file has been checked if Overwrite is FALSE
    
          transferOperationResult := WinSCPSession.PutFiles(SourceFileName,DestinationFileName,FALSE,transferOptions);
          transferOperationResult.Check;
        END;
    

    The filename parameters include absolute or relative paths as needed, formatted according to the file system they belong to.
  • spider1269spider1269 Member Posts: 77
    Thank you. I remember seeing this on the WinSCP site a while ago, but I didn't think it would work. I'll take another look at it since I now am able to use known file names.
Sign In or Register to comment.