FtpClient Members

System.Net.FtpClient

Collapse image Expand Image Copy image CopyHover image

The FtpClient type exposes the following members.

Constructors

  Name Description
Public method FtpClient
Creates a new isntance of FtpClient

Methods

  Name Description
Protected method Authenticate
Performs a login on the server. This method is overridable so that the login procedure can be changed to support, for example, a FTP proxy.
Public method BeginConnect
Initiates a connection to the server
Public method BeginCreateDirectory(String, AsyncCallback, Object)
Creates a directory asynchronously
Public method BeginCreateDirectory(String, Boolean, AsyncCallback, Object)
Creates a directory asynchronously
Public method BeginDeleteDirectory(String, AsyncCallback, Object)
Asynchronously removes a directory from the server
Public method BeginDeleteDirectory(String, Boolean, AsyncCallback, Object)
Asynchronously removes a directory from the server
Public method BeginDeleteDirectory(String, Boolean, FtpListOption, AsyncCallback, Object)
Asynchronously removes a directory from the server
Public method BeginDeleteFile
Asynchronously deletes a file from the server
Public method BeginDereferenceLink(FtpListItem, AsyncCallback, Object)
Derefence a FtpListItem object asynchronously. See the MaximumDereferenceCount property for controlling how deep this method will recurse before giving up.
Public method BeginDereferenceLink(FtpListItem, Int32, AsyncCallback, Object)
Derefence a FtpListItem object asynchronously
Public method BeginDirectoryExists
Checks if a directory exists on the server asynchronously.
Public method BeginDisconnect
Initiates a disconnection on the server
Public method BeginExecute
Performs an asynchronouse execution of the specified command
Public method BeginFileExists(String, AsyncCallback, Object)
Checks if a file exsts on the server by taking a file listing of the parent directory in the path and comparing the results the path supplied.
Public method BeginFileExists(String, FtpListOption, AsyncCallback, Object)
Checks if a file exsts on the server by taking a file listing of the parent directory in the path and comparing the results the path supplied.
Public method BeginGetFileSize
Asynchronously retrieve the size of the specified file
Public method BeginGetHash
Asynchronously retrieves the hash for the specified file
Public method BeginGetHashAlgorithm
Asynchronously get the hash algorithm being used by the HASH command.
Public method BeginGetListing(AsyncCallback, Object)
Gets a file listing from the server asynchronously
Public method BeginGetListing(String, AsyncCallback, Object)
Gets a file listing from the server asynchronously
Public method BeginGetListing(String, FtpListOption, AsyncCallback, Object)
Gets a file listing from the server asynchronously
Public method BeginGetModifiedTime
Gets the modified time of the file
Public method BeginGetNameListing(AsyncCallback, Object)
Asynchronously gets a list of file and directory names for the specified path.
Public method BeginGetNameListing(String, AsyncCallback, Object)
Asynchronously gets a list of file and directory names for the specified path.
Public method BeginGetWorkingDirectory
Asynchronously retrieves the working directory
Public method BeginOpenAppend(String, AsyncCallback, Object)
Opens the specified file for writing
Public method BeginOpenAppend(String, FtpDataType, AsyncCallback, Object)
Opens the specified file for writing
Public method BeginOpenRead(String, AsyncCallback, Object)
Opens the specified file for reading
Public method BeginOpenRead(String, Int64, AsyncCallback, Object)
Opens the specified file for reading
Public method BeginOpenRead(String, FtpDataType, AsyncCallback, Object)
Opens the specified file for reading
Public method BeginOpenRead(String, FtpDataType, Int64, AsyncCallback, Object)
Opens the specified file for reading
Public method BeginOpenWrite(String, AsyncCallback, Object)
Opens the specified file for writing
Public method BeginOpenWrite(String, FtpDataType, AsyncCallback, Object)
Opens the specified file for writing
Public method BeginRename
Asynchronously renames an object on the server
Protected method BeginSetDataType
Asynchronously sets the data type on the server
Public method BeginSetHashAlgorithm
Asynchronously sets the hash algorithm type to be used with the HASH command.
Public method BeginSetWorkingDirectory
Asynchronously changes the working directory on the server
Public method Connect()()()()
Connect to the server. Throws ObjectDisposedException if this object has been disposed.
Public method Static member Connect(Uri)
Connects to the specified URI. If the path specified by the URI ends with a / then the working directory is changed to the path specified.
Public method Static member Connect(Uri, Boolean)
Connects to the specified URI. If the path specified by the URI ends with a / then the working directory is changed to the path specified.
Public method CreateDirectory(String)
Creates a directory on the server. If the preceding directories do not exist they are created.
Public method CreateDirectory(String, Boolean)
Creates a directory on the server
Public method DeleteDirectory(String)
Deletes the specified directory on the server.
Public method DeleteDirectory(String, Boolean)
Delets the specified directory on the server
Public method DeleteDirectory(String, Boolean, FtpListOption)
Deletes the specified directory on the server
Public method DeleteFile
Deletes a file on the server
Public method DereferenceLink(FtpListItem)
Recursively dereferences a symbolic link. See the MaximumDereferenceCount property for controlling how deep this method will recurse before giving up.
Public method DereferenceLink(FtpListItem, Int32)
Recursively dereferences a symbolic link
Public method DirectoryExists
Tests if the specified directory exists on the server. This method works by trying to change the working directory to the path specified. If it succeeds, the directory is changed back to the old working directory and true is returned. False is returned otherwise and since the CWD failed it is assumed the working directory is still the same.
Public method DisableUTF8
Disables UTF8 support and changes the Encoding property back to ASCII. If the server returns an error when trying to turn UTF8 off a FtpCommandException will be thrown.
Public method Disconnect
Disconnect from the server
Public method Dispose
Disconnects from the server, releases resources held by this object.
Public method EndConnect
Ends an asynchronous connection attempt to the server
Public method EndCreateDirectory
Ends a call to BeginCreateDirectory
Public method EndDeleteDirectory
Ends a call to BeginDeleteDirectory()
Public method EndDeleteFile
Ends a call to BeginDeleteFile
Public method EndDereferenceLink
Ends a call to BeginDereferenceLink
Public method EndDirectoryExists
Ends a call to BeginDirectoryExists
Public method EndDisconnect
Ends a call to BeginDisconnect
Public method EndExecute
Ends an asynchronous command
Public method EndFileExists
Ends a call to BeginFileExists
Public method EndGetFileSize
Ends a call to BeginGetFileSize()
Public method EndGetHash
Ends an asynchronous call to BeginGetHash
Public method EndGetHashAlgorithm
Ends a call to BeginGetHashAlgorithm
Public method EndGetListing
Ends an asynchronous file listing
Public method EndGetModifiedTime
Ends a call to BeginGetModifiedTime()
Public method EndGetNameListing
Ends a call to BeginGetNameListing()
Public method EndGetWorkingDirectory
Ends an asynchronous call to retrieve the working directory
Public method EndOpenAppend
Ends a call to BeginOpenAppend()
Public method EndOpenRead
Ends a call to BeginOpenRead()
Public method EndOpenWrite
Ends a call to BeginOpenWrite()
Public method EndRename
Ends a call to BeginRename
Protected method EndSetDataType
Ends a call to BeginSetDataType()
Public method EndSetHashAlgorithm
Ends an asynchronous call to BeginSetHashAlgorithm
Public method EndSetWorkingDirectory
Ends asynchronous directory change
Public method Equals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public method Execute(String)
Executes a command
Public method Execute(String, array<Object>[]()[][])
Executes a command
Public method FileExists(String)
Checks if a file exsts on the server by taking a file listing of the parent directory in the path and comparing the results the path supplied.
Public method FileExists(String, FtpListOption)
Checks if a file exsts on the server by taking a file listing of the parent directory in the path and comparing the results the path supplied.
Protected method Finalize
Finalizer
(Overrides Object..::..Finalize()()()().)
Protected method GetAsyncDelegate<(Of <<'(T>)>>)
Retretieves the delegate for the specified IAsyncResult and removes it from the m_asyncmethods collection if the operation is successfull
Protected method GetFeatures
Populates the capabilities flags based on capabilities supported by this server. This method is overridable so that new features can be supported
Public method GetFileSize
Gets the size of the file
Public method GetHash
Gets the hash of an object on the server using the currently selected hash algorithm. Supported algorithms, if any, are available in the HashAlgorithms property. You should confirm that it's not equal to FtpHashAlgorithm.NONE before calling this method otherwise the server trigger a FtpCommandException() due to a lack of support for the HASH command. You can set the algorithm using the SetHashAlgorithm() method and you can query the server for the current hash algorithm using the GetHashAlgorithm() method. This feature is experimental and based on the following draft: http://tools.ietf.org/html/draft-bryan-ftpext-hash-02
Public method GetHashAlgorithm
Gets the currently selected hash algorith for the HASH command. This feature is experimental. See this link for details: http://tools.ietf.org/html/draft-bryan-ftpext-hash-02
Public method GetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public method GetListing()()()()
Gets a file listing from the server. Each FtpListItem object returned contains information about the file that was able to be retrieved. If a DateTime property is equal to DateTime.MinValue then it means the date in question was not able to be retrieved. If the Size property is equal to 0 then it means the size of the object could also not be retrieved.
Public method GetListing(String)
Gets a file listing from the server. Each FtpListItem object returned contains information about the file that was able to be retrieved. If a DateTime property is equal to DateTime.MinValue then it means the date in question was not able to be retrieved. If the Size property is equal to 0 then it means the size of the object could also not be retrieved.
Public method GetListing(String, FtpListOption)
Gets a file listing from the server. Each FtpListItem object returned contains information about the file that was able to be retrieved. If a DateTime property is equal to DateTime.MinValue then it means the date in question was not able to be retrieved. If the Size property is equal to 0 then it means the size of the object could also not be retrieved.
Public method GetModifiedTime
Gets the modified time of the file
Public method GetNameListing()()()()
Returns a file/directory listing using the NLST command.
Public method GetNameListing(String)
Returns a file/directory listing using the NLST command.
Public method GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method GetWorkingDirectory
Gets the current working directory
Public method HasFeature
Performs a bitwise and to check if the specified flag is set on the Capabilities enum property.
Protected method MemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public method OpenAppend(String)
Opens the specified file to be appended to
Public method Static member OpenAppend(Uri)
Opens a stream to the file specified by the URI
Public method OpenAppend(String, FtpDataType)
Opens the specified file to be appended to
Public method Static member OpenAppend(Uri, Boolean)
Opens a stream to the file specified by the URI
Public method Static member OpenAppend(Uri, Boolean, FtpDataType)
Opens a stream to the file specified by the URI
Public method OpenRead(String)
Opens the specified file for reading
Public method Static member OpenRead(Uri)
Opens a stream to the file specified by the URI
Public method OpenRead(String, Int64)
Opens the specified file for reading
Public method OpenRead(String, FtpDataType)
Opens the specified file for reading
Public method Static member OpenRead(Uri, Boolean)
Opens a stream to the file specified by the URI
Public method OpenRead(String, FtpDataType, Int64)
Opens the specified file for reading
Public method Static member OpenRead(Uri, Boolean, FtpDataType)
Opens a stream to the file specified by the URI
Public method Static member OpenRead(Uri, Boolean, FtpDataType, Int64)
Opens a stream to the file specified by the URI
Public method OpenWrite(String)
Opens the specified file for writing
Public method Static member OpenWrite(Uri)
Opens a stream to the file specified by the URI
Public method OpenWrite(String, FtpDataType)
Opens the specified file for writing
Public method Static member OpenWrite(Uri, Boolean)
Opens a stream to the file specified by the URI
Public method Static member OpenWrite(Uri, Boolean, FtpDataType)
Opens a stream to the file specified by the URI
Public method Rename
Renames an object on the remote file system.
Protected method SetDataType
Sets the data type of information sent over the data stream
Public method SetHashAlgorithm
Tells the server which hash algorith to use for the HASH command. If you specifiy an algorithm not listed in FtpClient.HashTypes a NotImplemented() exectpion will be thrown so be sure to query that list of Flags before selecting a hash algorithm. Support for the HASH command is experimental. Please see the following link for more details: http://tools.ietf.org/html/draft-bryan-ftpext-hash-02
Public method SetWorkingDirectory
Sets the work directory on the server
Public method ToString
Returns a String that represents the current Object.
(Inherited from Object.)

Extension Methods

  Name Description
Public Extension Method BeginGetChecksum
Asynchronusly retrieve a checksum of the specified file. This feature is non-standard.
(Defined by ChecksumExtension.)
Public Extension Method BeginGetMD5
Asynchronusly retrieve a MD5 hash. The MD5 command is non-standard and not guaranteed to work.
(Defined by MD5.)
Public Extension Method BeginGetXCRC
Asynchronusly retrieve a CRC hash. The XCRC command is non-standard and not guaranteed to work.
(Defined by XCRC.)
Public Extension Method BeginGetXMD5
Asynchronusly retrieve a MD5 hash. The XMD5 command is non-standard and not guaranteed to work.
(Defined by XMD5.)
Public Extension Method BeginGetXSHA1
Asynchronusly retrieve a SHA1 hash. The XSHA1 command is non-standard and not guaranteed to work.
(Defined by XSHA1.)
Public Extension Method BeginGetXSHA256
Asynchronusly retrieve a SHA256 hash. The XSHA256 command is non-standard and not guaranteed to work.
(Defined by XSHA256.)
Public Extension Method BeginGetXSHA512
Asynchronusly retrieve a SHA512 hash. The XSHA512 command is non-standard and not guaranteed to work.
(Defined by XSHA512.)
Public Extension Method GetChecksum
Retrieves a checksum of the given file using a checksumming method that the server supports, if any. The algorithm used goes in this order: 1. HASH command; server preferred algorithm. See FtpClient.SetHashAlgorithm() 2. MD5 / XMD5 commands 3. XSHA1 command 4. XSHA256 command 5. XSHA512 command 6. XCRC command
(Defined by ChecksumExtension.)
Public Extension Method GetMD5
Gets the MD5 hash of the specified file using MD5. This is a non-standard extension to the protocol and may or may not work. A FtpCommandException will be thrown if the command fails.
(Defined by MD5.)
Public Extension Method GetXCRC
Get the CRC value of the specified file. This is a non-standard extension of the protocol and may throw a FtpCommandException if the server does not support it.
(Defined by XCRC.)
Public Extension Method GetXMD5
Gets the MD5 hash of the specified file using XMD5. This is a non-standard extension to the protocol and may or may not work. A FtpCommandException will be thrown if the command fails.
(Defined by XMD5.)
Public Extension Method GetXSHA1
Gets the SHA-1 hash of the specified file using XSHA1. This is a non-standard extension to the protocol and may or may not work. A FtpCommandException will be thrown if the command fails.
(Defined by XSHA1.)
Public Extension Method GetXSHA256
Gets the SHA-256 hash of the specified file using XSHA256. This is a non-standard extension to the protocol and may or may not work. A FtpCommandException will be thrown if the command fails.
(Defined by XSHA256.)
Public Extension Method GetXSHA512
Gets the SHA-512 hash of the specified file using XSHA512. This is a non-standard extension to the protocol and may or may not work. A FtpCommandException will be thrown if the command fails.
(Defined by XSHA512.)

Properties

  Name Description
Protected property BaseStream
Gets the base stream for talking to the server via the control connection.
Public property Capabilities
Gets the server capabilties represented by flags
Public property ClientCertificates
Client certificates to be used in SSL authentication process
Public property ConnectTimeout
Gets or sets the length of time in miliseconds to wait for a connection attempt to succeed before giving up. Default is 15000 (15 seconds).
Public property Credentials
Credentials used for authentication
Public property DataConnectionConnectTimeout
Gets or sets the length of time in miliseconds for a data connection to be established before giving up. Default is 15000 (15 seconds).
Public property DataConnectionEncryption
Indicates if data channel transfers should be encrypted. Only valid if EncryptionMode property is not equal to FtpSslMode.None.
Public property DataConnectionReadTimeout
Gets or sets the length of time in miliseconds the data channel should wait for the server to send data. Default value is 15000 (15 seconds).
Public property DataConnectionType
Data connection type, default is AutoPassive which tries a connection with EPSV first and if it fails then tries PASV before giving up. If you know exactly which kind of connection you need you can slightly increase performance by defining a speicific type of passive or active data connection here.
Public property EnableThreadSafeDataConnections
When this value is set to true (default) the control connection is cloned and a new connection the server is established for the data channel operation. This is a thread safe approach to make asynchronous operations on a single control connection transparent to the developer.
Public property Encoding
Gets the text encoding being used when talking with the server. The default value is Encoding.ASCII however upon connection, the client checks for UTF8 support and if it's there this property is switched over to Encoding.UTF8.
Public property EncryptionMode
Type of SSL to use, or none. Default is none. Explicit is TLS, Implicit is SSL.
Public property HashAlgorithms
Get the hash types supported by the server, if any. This is a recent extension to the protocol that is not fully standardized and is not guarateed to work. See here for more details: http://tools.ietf.org/html/draft-bryan-ftpext-hash-02
Public property Host
The server to connect to
Public property InternetProtocolVersions
Flags specifying which versions of the internet protocol to support when making a connection. All addresses returned during name resolution are tried until a successful connection is made. You can fine tune which versions of the internet protocol to use by adding or removing flags here. I.e., setting this property to FtpIpVersion.IPv4 will cause the connection process to ignore IPv6 addresses. The default value is ANY version.
Public property IsConnected
Gets a value indicating if the connection is alive
Public property IsDisposed
Gets a value indicating if this object has already been disposed.
Public property MaximumDereferenceCount
Gets or sets a value that controls the maximum depth of recursion that DereferenceLink() will follow symbolic links before giving up. You can also specify the value to be used as one of the overloaded parameters to the DereferenceLink() method. The default value is 20. Specifying -1 here means inifinitly try to resolve a link. This is not recommended for obvious reasons (stack overflow).
Public property Port
The port to connect to. If this value is set to 0 (Default) the port used will be determined by the type of SSL used or if no SSL is to be used it will automatically connect to port 21.
Public property ReadTimeout
Gets or sets the length of time wait in miliseconds for data to be read from the underlying stream. The default value is 15000 (15 seconds).
Public property SocketKeepAlive
Gets or sets a value indicating if SocketOption.KeepAlive should be set on the underlying stream's socket. If the connection is alive, the option is adjusted in real-time. The value is stored and the KeepAlive option is set accordingly upon any new connections. The value set here is also applied to all future data streams. It has no affect on cloned control connections or data connections already in progress. The default value is false.
Public property SocketPollInterval
Gets or sets the length of time in miliseconds that must pass since the last socket activity before calling Poll() on the socket to test for connectivity. Setting this interval too low will have a negative impact on perfomance. Setting this interval to 0 disables Poll()'ing all together. The default value is 15 seconds.
Public property SystemType
Gets the type of system/server that we're connected to.
Public property UngracefullDisconnection
Disconnect from the server without sending QUIT. This helps work around IOExceptions caused by buggy connection resets when closing the control connection.

Events

  Name Description
Public event ValidateCertificate
Event is fired to validate SSL certificates. If this event is not handled and there are errors validating the certificate the connection will be aborted.

See Also