Upload a file with FTP in C# : The format of the URI could not be determined

前端 未结 1 807
别跟我提以往
别跟我提以往 2021-01-26 23:26

I\'m trying to upload a file with ftp in C#. for the moment, i try to do it locally:

static void Main(string[] args)
{
    UploadFileToFtp(\"C:\\\\Utilisateurs\\         


        
相关标签:
1条回答
  • 2021-01-27 00:01

    I think you are missing protocol: should be ftp://127.0.0.1/ instead of 127.0.0.1/. What's more, I suggest you to encode part of url that is stored in filePath. f.e:

    var encoded = HttpUtility.UrlEncode(filePath);
    var request = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/" + encoded)
    

    You need to reference System.Web assembly to use UrlEncode. More here.

    0 讨论(0)
提交回复
热议问题