This is an old revision of the document!

Session.MoveFile Method

Moves remote file to another remote directory and/or renames remote file.

Syntax

C#
public void MoveFile(string sourcePath, string targetPath)
VB.NET
Public Sub MoveFile(ByVal sourcePath As String, ByVal targetPath As String)

Parameters

Name Description
string sourcePath Full path to remote file to move/rename.
string targetPath Full path to new location and name1 to move/rename the file to.

Exceptions

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

Example

              RemoteDirectoryInfo lst = session.ListDirectory("/FTP/JASPER/*.eot"); // End of Transmission
              foreach (RemoteFileInfo file in lst.Files)
              {
                  Assert.IsNotNull(file);
                  string path = "/FTP/JASPER/";
                  string srcPath = path + file.Name;
                  string targetPath = path+@"done/" + file.Name;
                  session.MoveFile(srcPath, targetPath);
                  //return;
              }

Real-Life Example

  1. The name must be included or the target page has to end with a slash.Back

Last modified: by 217.33.90.252