FtpClient.Rename Method

System.Net.FtpClient

Collapse image Expand Image Copy image CopyHover image
Renames an object on the remote file system.

Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461

Syntax

C#
public void Rename(
	string path,
	string dest
)
Visual Basic
Public Sub Rename ( 
	path As String,
	dest As String
)
Visual C++
public:
virtual void Rename(
	String^ path, 
	String^ dest
) sealed

Parameters

path
Type: System..::..String
The full or relative path to the object
dest
Type: System..::..String
The old or new full or relative path including the new name of the object

Implements

IFtpClient..::..Rename(String, String)

Examples

C#  Copy imageCopy
using System;
using System.Net;
using System.Net.FtpClient;
using System.IO;

namespace Examples {
    public static class RenameExample {
        public static void Rename() {
            using (FtpClient conn = new FtpClient()) {
                conn.Host = "localhost";
                conn.Credentials = new NetworkCredential("ftptest", "ftptest");
                // renaming a directory is dependant on the server! if you attempt it
                // and it fails it's not because System.Net.FtpClient has a bug!
                conn.Rename("/full/or/relative/path/to/src", "/full/or/relative/path/to/dest");
            }
        }
    }
}

See Also