Discuss this help topic in SecureBlackbox Forum

TElSimpleSFTPClient.OpenFile

TElSimpleSFTPClient     See also     


Filter: C#/Java  VB.NET  Pascal  C++  PHP  


Opens a file on the server.

Declaration

[C#/Java]
    TSBSftpFileHandle OpenFile(string Filename, TSBSftpFileOpenModes Modes, TElSftpFileAttributes Attributes);
    TSBSftpFileHandle OpenFile(string Filename, TSBSftpFileOpenModes Modes, TSBSftpFileOpenAccess Access, TElSftpFileAttributes Attributes);
    
    TSBSftpFileHandle = byte[];
    TSBSftpFileOpenModes = int;
    TSBSftpFileOpenModes represents a bit mask which contains zero or more bit flags as defined by TSBSftpFileOpenMode
    TSBSftpFileOpenAccess = int;
    TSBSftpFileOpenAccess represents a bit mask which contains zero or more bit flags as defined by TSBSftpFileOpenAccessItem

[VB.NET]
    Function OpenFile(ByVal Filename As String, ByVal Modes As TSBSftpFileOpenModes, ByVal Attributes As TElSftpFileAttributes) As TSBSftpFileHandle
    function OpenFile(ByVal Filename As string, ByVal Modes As TSBSftpFileOpenModes, ByVal Access As TSBSftpFileOpenAccess, byVal Attributes As TElSftpFileAttributes) As TSBSftpFileHandle
    
    TSBSftpFileHandle As Byte()
    TSBSftpFileOpenModes As Integer
    TSBSftpFileOpenModes represents a bit mask which contains zero or more bit flags as defined by TSBSftpFileOpenMode
    TSBSftpFileOpenAccess As Integer
    TSBSftpFileOpenAccess represents a bit mask which contains zero or more bit flags as defined by TSBSftpFileOpenAccessItem

[Pascal]
    function OpenFileSync(const Filename: string; Modes: TSBSftpFileOpenModes; Attributes: TElSftpFileAttributes): TSBSftpFileHandle;
    function OpenFile(Filename : string; Modes : TSBSftpFileOpenModes; Attributes : TElSftpFileAttributes): TSBSftpFileHandle;
    
    TSBSftpFileHandle = ByteArray;
    TSBSftpFileOpenModes = set of TSBSftpFileOpenMode;
    TSBSftpFileOpenAccess = set of TSBSftpFileOpenAccessItem;

[C++]
    void OpenFile(const std::string &Filename, TSBSftpFileOpenModes Modes, TElSftpFileAttributes &Attributes, std::vector<uint8_t> &OutResult);
    void OpenFile(const std::string &Filename, TSBSftpFileOpenModes Modes, TElSftpFileAttributes *Attributes, std::vector<uint8_t> &OutResult);
    void OpenFile(const std::string &Filename, TSBSftpFileOpenModes Modes, TSBSftpFileOpenAccess Access, TElSftpFileAttributes &Attributes, std::vector<uint8_t> &OutResult);
    void OpenFile(const std::string &Filename, TSBSftpFileOpenModes Modes, TSBSftpFileOpenAccess Access, TElSftpFileAttributes *Attributes, std::vector<uint8_t> &OutResult);

[PHP]
    string OpenFile(string $Filename, integer $Modes, TElSftpFileAttributes $Attributes)
    string OpenFile(string $Filename, integer $Modes, integer $Access, TElSftpFileAttributes $Attributes)

Parameters

  • Filename - the name of the file to be opened.
  • Modes - specifies the file opening modes.
  • Attributes - specifies the initial attributes for the file.
  • Access - specifies if file must be blocked for reading, writing, or deleting while opened.

TSBSftpFileOpenAccess values

TSBSftpFileOpenModes values

TSBSftpFileOpenAccess values

Return value

    Returns handle to the opened file.

Description

    Use this method to open files on a server side.
    In case of error, EElSFTPError exception containing SFTP error code, is raised. For more information on error handling, please read the corresponding how-to article.

    The file is opened in binary mode, unless fmText flag is included to Modes parameter.

    After you have finished using the directory, close the handle with a call to CloseHandle() method.


    Note, the Access parameter has sense only for SFTPv5 and will be ignored for earlier versions.
    Note, setting of file opening mode differs for VCL and .NET versions. To enable several modes in .NET use bitwise OR operation, for example "fmRead | fmWrite | fmAppend".

See also:     CloseHandle     CreateFile     OpenStream     RemoveFile     Read     Write    

Discuss this help topic in SecureBlackbox Forum