GetFilePermissions Method  
 

Return the access permissions for a file on the server.

Syntax

object.GetFilePermissions( RemoteFile, 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
A numeric variable which is set to the file permissions when the method returns. This parameter must be passed by reference. The file permissions are represented as bit flags, and may be one or more of the following values:
Value Constant Description
1 filePermWorldExecute All users have permission to execute the contents of the file. If this permission is set for a directory, this may also grant all users the right to open that directory and search for files in that directory.
2 filePermWorldWrite All users have permission to open the file for writing. This permission grants any user the right to replace the file. If this permission is set for a directory, this grants any user the right to create and delete files.
4 filePermWorldRead All users have permission to open the file for reading. This permission grants any user the right to download the file to the local system.
8 filePermGroupExecute Users in the specified group have permission to execute the contents of the file. If this permission is set for a directory, this may also grant the user the right to open that directory and search for files in that directory.
16 filePermGroupWrite Users in the specified group have permission to open the file for writing. On some platforms, this may also imply permission to delete the file. If the current user is in the same group as the file owner, this grants the user the right to replace the file. If this permission is set for a directory, this grants the user the right to create and delete files.
32 filePermGroupRead Users in the specified group have permission to open the file for reading. If the current user is in the same group as the file owner, this grants the user the right to download the file.
64 filePermOwnerExecute The owner has permission to execute the contents of the file. The file is typically either a binary executable, script or batch file. If this permission is set for a directory, this may also grant the user the right to open that directory and search for files in that directory.
128 filePermOwnerWrite The owner has permission to open the file for writing. If the current user is the owner of the file, this grants the user the right to replace the file. If this permission is set for a directory, this grants the user the right to create and delete files.
256 filePermOwnerRead The owner has permission to open the file for reading. If the current user is the owner of the file, this grants the user the right to download the file to the local system.
4096 filePermSymbolicLink The file is a symbolic link to another file. Symbolic links are special types of files found on UNIX based systems which are similar to Windows shortcuts.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The GetFilePermissions method returns information about the access permissions for a specific file on the server. This method uses the STAT command to retrieve information about the specified file. If the server does not support the use of this command, an error will be returned. You can use the Features property to determine what features are available and/or enabled on the server.

Note that on some systems, the STAT command will not return information on files that contain spaces or tabs in the filename. In this case, the method will fail.

Example

The following example demonstrates how to retrieve the access permissions for a file and then test to see if the file can be read by the owner of that file:

nError = FileTransfer1.GetFilePermissions(strFileName, nFilePerms)
If nError > 0 Then
    MsgBox FileTransfer1.LastErrorString, vbExclamation
    Exit Sub
End If

If (nFilePerms And filePermOwnerRead) <> 0 Then
    MsgBox "The file " & strFileName & " can be read by the owner"
End If

See Also

Features Property, SetFilePermissions Method