Keyword Index

Object: SPFTP

An SPFTP object is used to connect to an FTP site and perform uploads, downloads, and other FTP operations. An SPFTP object is created using the SPNet.SPFTP method.

  • close - Closes the connection to the FTP server.
  • createDirectory - Creates a directory on the FTP server.
  • deleteDirectory - Deletes a directory from the FTP server.
  • deleteFile - Deletes a file from the FTP server.
  • directory - Gets or sets the current directory for this FTP connection.
  • getFileList
  • lastError - Returns the internal error code of the last operation. This will be zero if no error
  • lastErrorString - Returns a human-readable string describing any error from the last operation. This will be empty if no error.
  • readBinary
  • readText
  • rename - Renames a file on the FTP server.
  • wait - Waits for the operation to finish, an error to occur, or the given amount of time to elapse, whichever comes first.
  • write
  • writeBinary - Uploads a binary data block to an FTP server.
  • writeText - Uploads a text data block to an FTP file.
  • Method: close

    Closes the connection to the FTP server.

    void close();

    Method: createDirectory

    Creates a directory on the FTP server.

    void createDirectory(dirName);

    Parameters
    Name Expected Type Description
    dirName String The name of the directory to create on the remote server.

    Method: deleteDirectory

    Deletes a directory from the FTP server.

    void deleteDirectory(dirName);

    Parameters
    Name Expected Type Description
    dirName String The name of the directory on the remote server to delete.

    Method: deleteFile

    Deletes a file from the FTP server.

    void deleteFile(fileName);

    Parameters
    Name Expected Type Description
    fileName String The name of the file on the remote server to delete.

    Property: directory

    Gets or sets the current directory for this FTP connection.

    String = directory

    directory = String

    Errors:

    No errors are reported

    Method: getFileList

    SPArray getFileList();

    SPArray getFileList(pattern);

    Parameters
    Name Expected Type Description
    pattern String A file name pattern, e.g. "*.zip". Only files matching this pattern will be returned.

    Returns:

    Returns an array of objects of type SPFile containing the names of the matched files.

    Property: lastError

    Returns the internal error code of the last operation. This will be zero if no error

    int lastError();

    Property: lastErrorString

    Returns a human-readable string describing any error from the last operation. This will be empty if no error.

    String lastErrorString();

    Method: readBinary

    SPArray readBinary(fileName);

    Parameters
    Name Expected Type Description
    fileName String The name of the file to download, i.e. the name on the FTP site.

    Returns:

    Returns an array of bytes containing the data downloaded.

    Errors:

    If any error occurs, an exception is generated.

    Remarks:

    The data is not stored in a local file, it is only returned in memory as an array.

    Method: readText

    String readText(fileName);

    Parameters
    Name Expected Type Description
    fileName String The name of the file to download, i.e. the name on the FTP site.

    Returns:

    Returns a string containing the download data, converted to text.

    Errors:

    If any error occurs, an exception is generated.

    Remarks:

    The data is not stored in a local file, it is only returned in as a string.

    Method: rename

    Renames a file on the FTP server.

    void rename(oldName, newName);

    Parameters
    Name Expected Type Description
    oldName String The current name of the file on the remote server.
    newName String The desired new name.

    Method: wait

    Waits for the operation to finish, an error to occur, or the given amount of time to elapse, whichever comes first.

    bool wait();

    bool wait(millis);

    Parameters
    Name Expected Type Description
    millis int The maximum number of milliseconds to wait. If this is not specified, the call waits forever.

    Returns:

    Returns true if the operation completed without any error.

    Method: write

    bool write(remoteFileName, data);

    Parameters
    Name Expected Type Description
    remoteFileName String The name under which the data will be saved on the FTP server
    data data Any data item.

    Remarks:

    This method behaves like writeText if the data argument is a string, writeBinary otherwise.

    Method: writeBinary

    Uploads a binary data block to an FTP server.

    bool writeBinary(remoteFileName, data);

    Parameters
    Name Expected Type Description
    remoteFileName String The name under which the data will be saved on the FTP server
    data data Any data item that can be converted to binary.

    Errors:

    If any error occurs and a return value is assigned, this method will return true if the write completed OK, false if any error occurred. If an error occurs and no return value is assigned, an exception is generated.

    Method: writeText

    Uploads a text data block to an FTP file.

    bool writeText(remoteFileName, text);

    Parameters
    Name Expected Type Description
    remoteFileName String The name under which the data will be saved on the FTP server
    text String The text to upload.

    Errors:

    If any error occurs and a return value is assigned, this method will return true if the write completed OK, false if any error occurred. If an error occurs and no return value is assigned, an exception is generated.