Back to product page

SetAttributes method


Sets attributes for a file or folder.

Type

Void

Syntax

  • C#
  • VB.NET
public Void SetAttributes(Int64 Permissions);
The SetAttributes(Permissions) syntax has these parts:
PermissionsNew permissions.

public Void SetAttributes(UInt64 Size);
The SetAttributes(Size) syntax has these parts:
SizeNew file/directory size.

public Void SetAttributes(Int64 Uid, Int64 Gid);
The SetAttributes(Uid,Gid) syntax has these parts:
UidUser ownership for file/directory.
GidGroup ownership for file/directory.

public Void SetAttributes(DateTime AccessTime, DateTime ModificationTime);
The SetAttributes(AccessTime,ModificationTime) syntax has these parts:
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Void SetAttributes(String RemotePath, Int64 Permissions);
The SetAttributes(RemotePath,Permissions) syntax has these parts:
RemotePathFull path to a file on remote system.
PermissionsNew permissions.

public Void SetAttributes(String RemotePath, UInt64 Size);
The SetAttributes(RemotePath,Size) syntax has these parts:
RemotePathFull path to a file on remote system.
SizeNew file/directory size.

public Void SetAttributes(String RemotePath, Int64 Uid, Int64 Gid);
The SetAttributes(RemotePath,Uid,Gid) syntax has these parts:
RemotePathFull path to a file on remote system.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.

public Void SetAttributes(String RemotePath, DateTime AccessTime, DateTime ModificationTime);
The SetAttributes(RemotePath,AccessTime,ModificationTime) syntax has these parts:
RemotePathFull path to a file on remote system.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Void SetAttributes(UInt64 Size, Int64 Uid, Int64 Gid, Int64 Permissions, DateTime AccessTime, DateTime ModificationTime);
The SetAttributes(Size,Uid,Gid,Permissions,AccessTime,ModificationTime) syntax has these parts:
SizeNew file/directory size.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.
PermissionsNew permissions.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Void SetAttributes(String RemotePath, UInt64 Size, Int64 Uid, Int64 Gid, Int64 Permissions, DateTime AccessTime, DateTime ModificationTime);
The SetAttributes(RemotePath,Size,Uid,Gid,Permissions,AccessTime,ModificationTime) syntax has these parts:
RemotePathFull path to a file/directory on the server.
SizeNew file/directory size.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.
PermissionsNew permissions.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Sub SetAttributes(ByVal Permissions As Int64)
The SetAttributes(Permissions) syntax has these parts:
PermissionsNew permissions.

public Sub SetAttributes(ByVal Size As UInt64)
The SetAttributes(Size) syntax has these parts:
SizeNew file/directory size.

public Sub SetAttributes(ByVal Uid As Int64, ByVal Gid As Int64)
The SetAttributes(Uid,Gid) syntax has these parts:
UidUser ownership for file/directory.
GidGroup ownership for file/directory.

public Sub SetAttributes(ByVal AccessTime As DateTime, ByVal ModificationTime As DateTime)
The SetAttributes(AccessTime,ModificationTime) syntax has these parts:
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Sub SetAttributes(ByVal RemotePath As String, ByVal Permissions As Int64)
The SetAttributes(RemotePath,Permissions) syntax has these parts:
RemotePathFull path to a file on remote system.
PermissionsNew permissions.

public Sub SetAttributes(ByVal RemotePath As String, ByVal Size As UInt64)
The SetAttributes(RemotePath,Size) syntax has these parts:
RemotePathFull path to a file on remote system.
SizeNew file/directory size.

public Sub SetAttributes(ByVal RemotePath As String, ByVal Uid As Int64, ByVal Gid As Int64)
The SetAttributes(RemotePath,Uid,Gid) syntax has these parts:
RemotePathFull path to a file on remote system.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.

public Sub SetAttributes(ByVal RemotePath As String, ByVal AccessTime As DateTime, ByVal ModificationTime As DateTime)
The SetAttributes(RemotePath,AccessTime,ModificationTime) syntax has these parts:
RemotePathFull path to a file on remote system.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Sub SetAttributes(ByVal Size As UInt64, ByVal Uid As Int64, ByVal Gid As Int64, ByVal Permissions As Int64, ByVal AccessTime As DateTime, ByVal ModificationTime As DateTime)
The SetAttributes(Size,Uid,Gid,Permissions,AccessTime,ModificationTime) syntax has these parts:
SizeNew file/directory size.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.
PermissionsNew permissions.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

public Sub SetAttributes(ByVal RemotePath As String, ByVal Size As UInt64, ByVal Uid As Int64, ByVal Gid As Int64, ByVal Permissions As Int64, ByVal AccessTime As DateTime, ByVal ModificationTime As DateTime)
The SetAttributes(RemotePath,Size,Uid,Gid,Permissions,AccessTime,ModificationTime) syntax has these parts:
RemotePathFull path to a file/directory on the server.
SizeNew file/directory size.
UidUser ownership for file/directory.
GidGroup ownership for file/directory.
PermissionsNew permissions.
AccessTimeSets last access time.
ModificationTimeSets last modification time.

Remarks

The SetAttributes method is used to set certain attributes for the file or directory on the server. Although all parameters are optional you should set at least one parameter for this method to actually send a request to the server. If RemoteFile is not set, then the RemotePath property will be used as the file/directory name whose attributes are set.

IMPORTANT : if you set the file UID, also set GID in same function call (and vice versa). This is the way setting attributes works. The same applies when setting AccessTime and ModificationTime. If you omit one of these parameters while setting the other, it will be set to 0 (representing Jan 1, 1970).

If you want to set only one of these parameters, you should first retrieve the attributes of the file/directory and use these retrieved values in this method.

The value for Permissions is defined by the POSIX standard, usually represented in octal (base 8) to make parsing them easier.
Permissions AND 777 (octal) will give you read/write/execute permissions for owner, group and others. To be more precise, 1 indicates execute permission, 2 indicates write permission, 4 indicates read permission. For example, if file Permission AND 777 (octal) gives 754, this is represented on the server as -rwxr-xr-- which means: the owner can read/write/execute, the group can read/execute, and others can only read.

To determine if an attribute belongs to directory, test for Permissions AND 40000 (octal). To determine if an attribute belongs to a symbolic link, test for Permissions AND 120000 (octal).

However, when you supply Permission value you must provide it in DECIMAL! That means that 777 oct will be 511 dec, and you must set 511 as Permission, to become 777 on remote side. Same rule applies for all protocols!

WARNING: in protocols other than SFTP this method will allow only limited subset of available attributes to be set. Since there is no common way to set all of them, you can set only one set of attributes at a time (either Size, UID+GID, Permissions, ATIME+MTIME). If you try to set more than one using one SetAttributes call, component will return an error.
Currently you can only set Permissions (with SITE CHMOD command) and ModificationTime (through MFMT/MDTM commands). Other values will be ignored. We are open for any ideas to extend these protocols so they support full subset - as in SFTP protocol.

Platforms

Windows