Here I have downloaded the file "file.txt" on the server, and I need to rename it without transfer. As I understand it, you need to use FTP, but how?
1 answer
It all depends on what protocol you have access to this file storage and what kind of file storage it is.
If the server has a Windows OS and a file in a “shared” folder, or some other SMB server, then there is no problem renaming the file using System.IO.File.Move .
If the file storage is available via FTP , then you can use FtpWebRequest :
var requestFTP = (FtpWebRequest)FtpWebRequest.Create( new Uri("ftp://" + ftpServer + "/" + destination + "/" + fileName)); requestFTP.Proxy = null; requestFTP.Credentials = new NetworkCredential(ftpUser, ftpPassword); string newFilename = "<new file name>"; requestFTP.Method = WebRequestMethods.Ftp.Rename; requestFTP.RenameTo = newFilename; requestFTP.GetResponse(); - I have a server from ucoz. Is System.IO.File.Move suitable for it? - Minebot
- @Minebot Honestly, I don’t know how ucoz provides access to file storage. Let's link to the documentation. - Zverev Evgeniy
- @Eugene Server like CMS. And the documentation is here: manual.ucoz.net or this (I xs ): api.ucoz.net/ru/manual#modules - Minebot
- @Minebot CMS is not a file storage protocol, it is a Content Management System, usually there is some kind of user interface behind content management for something. I found the documentation myself: faq.ucoz.com/faq/21-1 , you can use FTP. - Zverev Evgeniy
- Thanks a lot , it all worked - Minebot
|