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.

Syntax

C#
public RemovalEventArgs RemoveFile(string path)
VB.NET
Public Function RemoveFile(path As String) As RemovalEventArgs

Parameters

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

Return Value

RemovalEventArgs.

Exceptions

Exception Condition
InvalidOperationException Session is not opened.
SessionLocalException Error communicating with winscp.com.
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 winscp.com to respond.

Remarks

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