在c#中的webclient UploadStringTaskAsync中启用ssl

时间:2018-11-29 16:54:14

标签: c# asp.net .net ftp ftps

我目前有ftp可以正常工作,但是现在我想要ssl认证并启用ssl

当前代码:

 public async Task FtpFileAsync(string path, string newName = null)
        {
            try
            {
                using (var wc = new WebClient())
                {
                    wc.Credentials = new NetworkCredential(config.Username, config.Password);
                    wc.Encoding = Encoding.UTF8;
                    var address = String.IsNullOrEmpty(newName) ? config.Url + Path.GetFileName(path) : config.Url + newName;
                    var response = await wc.UploadStringTaskAsync(address,WebRequestMethods.Ftp.UploadFile,GetFileContent(path));

            }
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine(e);
            throw;
        }
    } 

0 个答案:

没有答案