Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FtpWebRequest move file

Tags:

c#

.net

vb.net

ftp

I am putting together a simple app and I have it working for uploading, downloading, deleting files using FtpWebRequest. But I cannot find how to move a file using FtpWebRequest. What is the simplest way to move a file from one dir to another without using another external dependancy? Thanks in advance.

like image 440
user160185 Avatar asked Aug 20 '09 16:08

user160185


People also ask

Can you move files in FTP?

You can transfer files from your system to or from the product by using FTP in a number of ways: You can use a command-line program FTP, which many operating systems are providing. You can use one of many FTP client products with a graphical user interface. You can select the FTP protocol on your web browser.

Does FTP have a Move command?

To transfer files to another computer, open an FTP connection to that computer. To move files from the current directory of your computer, use the mput command.


1 Answers

Create a FtpWebRequest with the source file name, set the Method-Property of the FtpWebRequest to Use System.Net.WebRequestMethods.Ftp.Rename and set the RenameTo-Property of the FtpWebRequest to the new file name.

FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("oldName");
request.Method = System.Net.WebRequestMethods.Ftp.Rename;
request.RenameTo = "newName";
like image 177
PVitt Avatar answered Sep 21 '22 04:09

PVitt