SocketTools .NET Edition

FileTransfer.SetFilePermissions Method 

Change the access permissions for a file on the server.

[Visual Basic]
Public Function SetFilePermissions( _
   ByVal remoteFile As String, _
   ByVal filePerms As FilePermissions _
) As Boolean
[C#]
public bool SetFilePermissions(
   string remoteFile,
   FilePermissions filePerms
);

Parameters

remoteFile
A string that specifies the name of the file that the access permissions are to be returned for. The filename cannot contain any wildcard characters.
filePerms
An FilePermissions enumeration which specifies the new permissions for the file.

Return Value

This method returns a Boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

This method uses the SITE CHMOD command to set the permissions for the file. This command is typically only supported on servers that are hosted on UNIX based systems. If the command is not supported, an error will be returned. You can use the Features property to determine what features are available and/or enabled on the server.

Users who are familiar with the UNIX operating system will recognize the chmod command used to change the file permissions. However, it should be noted that the numeric value used as an argument to the command is in octal, not decimal. For example, issuing the command chmod 644 filename.txt on a UNIX based system will make the file readable and writable by the owner, and readable by other users in the owner's group as well as all other users. The value 644 is an octal value, which is equivalent to the decimal value 420. If you were to mistakenly specify 644 as the value for the Permissions argument, rather than the decimal value of 420, the permissions on the file would be incorrect. It is strongly recommended that you use the enumeration values and do not cast a numeric value as the argument.

Note that Visual Basic allows you to specify an integer value in octal by prefixing it with &O. For example, &O644 could be used as the file permissions value. C# and C++ consider any integer with a preceding 0 to be an octal number, so 0644 would be a valid permissions value.

See Also

FileTransfer Class | SocketTools Namespace