How to rename a file after upload

后端 未结 2 1444
一生所求
一生所求 2020-12-21 17:44

I have to upload file using Ftp protocol on server, and rename uploaded file after uploading.

I can upload it, but don\'t know how to rename it.

Code looks l

2条回答
  •  生来不讨喜
    2020-12-21 18:21

    Why not just upload it with the correct filename in stead? Change your first line with the filename you actually want.

    FtpWebRequest requestFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServer + "/" + "httpdocs/webroot/" + destination + "/" + newFileName));
    

    But do open the reading stream from your old filename.

提交回复
热议问题