Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,
i want to move xml file from ftp folder 1 to folder 2. but it not happend download file from local folder not neccesary directly move to folder 1 to folder 2 is it posible ??

pls give some suggestion its very urgent pls help me...




Thanks in Advance.
Athi Varathan
Posted
Comments
Prasad Khandekar 24-May-13 3:20am    
Hello Athi,

For moving a file on FTP you use "rename" command. The rename command takes two arguments the first argument is the full path & name of the source file and the second argument is the full path & name of the destination.

You also need to ensure that the FTP users has right permissions to the source and destination folder.

From RAW FTP command perspective you use RNFR followed by RNTO. RNFR stands for Rename From and RNTO stands for Rename To. The RNFT command takes the full path & name of file to be moved and RNTO command takes full path and name of the destination. (http://www.nsftools.com/tips/RawFTP.htm).

You can use FtpWebRequest in System.Net to achieve the same. The code might look something like the one shown below.

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://HOST/FOLDER1/MYFILE.XML");
request.Method = WebRequestMethods.Ftp.Rename;
request.Credentials = new NetworkCredential ("USER_ID", "PASSWORD");
request.RenameTo = "/FOLDER2/MYFILE.XML";
FtpWebResponse response = (FtpWebResponse) request.GetResponse();
Console.WriteLine("Move status: {0}", response.StatusDescription);
response.Close();

Regards,
walterhevedeich 24-May-13 3:35am    
What have you tried? Post your code and we can start from there.

1 solution

The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900