Session.RemoveFile Method

Removes one specific remote file.

This is a convenient alternative to Session.RemoveFiles, when you want to remove only one specific file.


public RemovalEventArgs RemoveFile(string path)
Public Function RemoveFile(path As String) As RemovalEventArgs


Name Description
string path Full path to the remote file to remove.

Return Value



Exception Condition
InvalidOperationException Session is not opened.
SessionLocalException Error communicating with
See the exception documentation for details.
SessionRemoteException Session has failed.
Removing of the file has failed.
See the exception documentation for details.
TimeoutException Timeout waiting for to respond.


Contrary to Session.RemoveFiles:

  • You specify a path to the remote file, not a wildcard, so you do not need to escape a literal file name.
  • The method removes files only. It throws when the path points to a directory.
  • The method throws an exception on an error automatically.

Last modified: by martin