EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Info: How to set file attributes

Posted: 02/22/2008 06:28:56
by Eugene Mayevski (Team)

We've improved the SimpleSftp sample application to show how to set the attributes of the file after uploading.

Here are code snippets for this:

ActiveX edition:
    ' Adjust attributes for the remote file
    Dim Attrs As New ElSftpFileAttributesX
    Attrs.CTime = Date
    Attrs.ATime = Attrs.CTime
    Attrs.MTime = Attrs.CTime
    Attrs.IncludeAttribute SB_SFTP_ATTR_ATIME
    Attrs.IncludeAttribute SB_SFTP_ATTR_CTIME
    Attrs.IncludeAttribute SB_SFTP_ATTR_MTIME
    Call SftpClient.SetAttributes(RemoteName, Attrs)    

.NET edition, VB.NET:
                        ' now adjust the attributes of the uploaded file
                        Dim Attrs As TElSftpFileAttributes
                        Attrs = New TElSftpFileAttributes()
                        Attrs.CTime = DateTime.Now
                        Attrs.MTime = Attrs.CTime
                        Attrs.ATime = Attrs.CTime
                        Attrs.CATime = Attrs.CTime

                        Attrs.IncludedAttributes = SBSftpCommon.__Global.saATime Or SBSftpCommon.__Global.saMTime Or SBSftpCommon.__Global.saCTime Or SBSftpCommon.__Global.saCATime
                        SftpClient.SetAttributes(remoteName, Attrs)

.NET edition, C#:
                     // now adjust the attributes of the uploaded file
                     TElSftpFileAttributes Attrs = new TElSftpFileAttributes();
                     Attrs.CTime = DateTime.Now;
                     Attrs.MTime = Attrs.CTime;
                     Attrs.ATime = Attrs.CTime;
                     Attrs.CATime = Attrs.CTime;

                     Attrs.IncludedAttributes = SBSftpCommon.__Global.saATime | SBSftpCommon.__Global.saMTime | SBSftpCommon.__Global.saCTime | SBSftpCommon.__Global.saCATime;
                     SftpClient.SetAttributes(remoteName, Attrs);

VCL edition, Delphi:
          Attrs := TElSftpFileAttributes.Create;
            Attrs.MTime := Now;
            Attrs.ATime := Attrs.MTime;
            Attrs.CTime := Attrs.MTime;
            Attrs.CATime := Attrs.MTime;
            Attrs.IncludedAttributes := [saATime, saMTime, saCTime, saCATime];
            SftpClient.SetAttributes(FName, Attrs);

VCL edition, C++:
                 TElSftpFileAttributes* Attrs = new TElSftpFileAttributes();
                   Attrs->MTime = Now();
                    Attrs->CTime = Attrs->MTime;
                    Attrs->ATime = Attrs->MTime;
                    Attrs->CATime = Attrs->MTime;
                    Attrs->IncludedAttributes << saATime << saMTime << saCTime << saCATime;
                    SftpClient->SetAttributes(FCurrentDir + "/" + shortName, Attrs);
                   delete Attrs;

Sincerely yours
Eugene Mayevski



Topic viewed 2664 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!