我需要帮助,没有我似乎无法找到解决我的问题的方法。
我正在尝试在 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
我收到以下错误:
我已经在网上尝试了所有方法,但似乎没有任何效果,有人可以告诉我哪里出了问题。谢谢你