Skip to content

File Management

Robin Rodricks edited this page Jun 14, 2023 · 9 revisions

API

Tip: For detailed documentation refer to the IntelliSense tips that appear when you call a given API method.

Working directory (relative paths are relative to this directory):

  • GetWorkingDirectory() - Gets the full path of the current working directory.

  • SetWorkingDirectory() - Sets the full path of the current working directory. All relative paths are relative to the working directory.

Directories:

  • DirectoryExists() - Check if a directory exists on the server.

  • CreateDirectory() - Creates a directory on the server. If the parent directories do not exist they are also created.

  • DeleteDirectory() - Deletes the specified directory on the server. If it is not empty then all subdirectories and files are recursively deleted.

  • EmptyDirectory() - Empties the specified directory on the server recursively without removing it.

  • MoveDirectory() - Moves a directory from one place to another on the server. The destination directory is deleted before moving if FtpExists.Overwrite is used. Only throws exceptions for critical errors.

Files:

  • FileExists() - Check if a file exists on the server.

  • DeleteFile() - Deletes the specified file on the server.

  • MoveFile() - Moves a file from one directory to another on the server. The destination file is deleted before moving if FtpExists.Overwrite is used. Only throws exceptions for critical errors.

  • Rename() - Renames the file/directory on the server. Low level method that should NOT be used in most cases. Prefer MoveFile() and MoveDirectory(). Throws exceptions if the source does not exist, or if the destination already exists.

  • GetModifiedTime() - Gets the last modified date/time of the file or folder, converted into the format specified in the timezone configuration. This means that if you are using FtpDate.UTC, then the result timestamp will be in the UTC format.

  • SetModifiedTime() - Modifies the last modified date/time of the file or folder, converted back from the format specified in the timezone configuration. This means that if you are using FtpDate.UTC, then you need to provide the date in the UTC format.

  • GetFileSize() - Gets the size of the file in bytes, or -1 if not found.

  • DereferenceLink() - Recursively dereferences a symbolic link and returns the full path if found. The MaximumDereferenceCount property controls how deep we recurse before giving up.

Examples

C#

VB.NET

Clone this wiki locally