我需要帮助,我似乎无法找到解决问题的方法。
我正在尝试在FTP服务器中创建一个目录:
Dim request As FtpWebRequest = FtpWebRequest.Create("ftp:\\*******")
Dim creds As NetworkCredential = New NetworkCredential("****", "*****")
request.Credentials = creds
request.KeepAlive = True
request.EnableSsl = True
request.UsePassive = True
request.Timeout = 10000000
request.ReadWriteTimeout = 10000000
ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf customCertValidation)
Dim resp As FtpWebResponse = Nothing
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
Using resp
resp = request.GetResponse()
Dim sr As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.ASCII)
Dim s As String = sr.ReadToEnd()
If Not s.Contains("newfolder") Then
request = FtpWebRequest.Create("ftp:\\********")
request.Credentials = creds
request.Method = WebRequestMethods.Ftp.MakeDirectory
resp = request.GetResponse()
Console.WriteLine(resp.StatusCode & "Created")
Else
Console.WriteLine("Directory already exists")
End If
End Using
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
customCertValidation函数
Function customCertValidation(ByVal sender As Object,
ByVal cert As X509Certificate,
ByVal chain As X509Chain,
ByVal errors As SslPolicyErrors) As Boolean
Return True
End Function
我收到以下错误:
我已尝试过网络上的所有内容,但似乎没有任何效果,有人可以告诉我出了什么问题。 谢谢