Rename file using FTP

To rename a file stored on the FTP server you just need use Rename method:

// C# version

using (Ftp client = new Ftp())
{
    client.Connect("ftp.example.org");
    client.Login("user", "password");

    // You can rename files:
    client.Rename("reports/report.txt", "reports/report_2010.txt");

    // You can also rename folders using the same method:
    client.Rename("folder", "folder2");

    client.Close();
}
' VB.NET version

Using client As New Ftp()
	client.Connect("ftp.example.org")
	client.Login("user", "password")

	' You can rename files:
	client.Rename("reports/report.txt", "reports/report_2010.txt")

	' You can also rename folders using the same method:
	client.Rename("folder", "folder2")

	client.Close()
End Using

You can download Ftp.dll FTP/FTPS library for .NET here.

Tags:    

Questions?

Consider using our Q&A forum for asking questions.