我正在尝试从我的VB.net应用程序上传文件到Mainframe机器。我收到以下错误。
远程服务器返回错误:(501)参数或参数中的语法错误
以下是我的代码。任何帮助将不胜感激。
Dim urlHost As String = "ftp://" + FWFTP.Default.TargetFTPHost.ToString()
Dim url As String = "ftp://" + FWFTP.Default.TargetFTPHost & "/" & FWFTP.Default.TargetFolder & "/" & fileName
Dim clsRequest As System.Net.FtpWebRequest = CType(WebRequest.Create(url), FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(FWFTP.Default.FTPUserName.ToString(), FWFTP.Default.FTPPassword.ToString())
clsRequest.Proxy = Nothing
Dim target As New Uri(urlHost)
Dim iphe() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses(target.Host)
If My.Computer.Network.Ping(iphe(0).ToString, 200) = False Then
MsgBox("Ping: " + urlHost + ":" + iphe(0).ToString + " Failed")
'ElseIf FTPSite <> "" Then
End If
clsRequest.KeepAlive = False
clsRequest.UseBinary = False
clsRequest.UsePassive = True
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(fullPath)
' upload file...
Dim clsStream As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
答案 0 :(得分:2)
当你说'大型机'时,任何机会都不会是AS / 400?
特别是,请参阅this thread
中FTPOdyssey的建议答案 1 :(得分:0)
当您使用System.Net.WebClient或FtpWebRequest时,如果要访问以下ftp url,请访问Z / Os主机(请注意密码中的@):
ftp://userid:p@ssword@host/pub/data/msg.log
您必须执行以下操作:
ftp://userid:%40ssword@host/%2Fpub/data/msg.log
这应该适用于下载或上传。