System.Net.WebException命令无法识别

时间:2014-04-29 11:06:45

标签: vb.net upload ftp webexception

我正在尝试将图片上传到ftp。我可以使用filezilla或explorer进行连接。但是,当我使用vb.net代码时,我收到错误:System.Net.WebException:远程服务器返回错误:(500)语法错误,命令无法识别。请帮忙。我生气了。我正在使用的代码:

Public Sub upload2ftp(ByVal _FileName As String, ByVal _UploadPath As String, ByVal _FTPUser As String, ByVal _FTPPass As String) Try Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(_UploadPath), System.Net.FtpWebRequest) request.Credentials = New System.Net.NetworkCredential(_FTPUser, _FTPPass) request.Method = System.Net.WebRequestMethods.Ftp.UploadFile request.UsePassive = False request.KeepAlive = False Dim file() As Byte = System.IO.File.ReadAllBytes(_FileName) Dim strz As System.IO.Stream = request.GetRequestStream() strz.Write(file, 0, file.Length) strz.Close() strz.Dispose() Catch ex As Exception MsgBox(ex.ToString) End Try

1 个答案:

答案 0 :(得分:0)

问题是卡巴斯基。关闭它,上传进展顺利。