以下是将字节数组上传到我们大型机上的文件 DSN 的代码。它工作得很好。我想要做的是上传应该开始执行的 jcl。这就是我坚持的部分。我以前可以通过 WININET 来完成,但我想摆脱这种情况并在 vb.net 中使用更好的 FTP 命令
Public Shared Sub UploadToMainFrame( _
ByVal ftpHost As String, _
ByVal ftpMainframeDSN As String, _
ByVal UserName As String, _
ByVal Password As String, _
ByVal DataToUpload As String)
Dim ftpRequest As FtpWebRequest
Dim ftpFullMainframePath = String.Format("ftp://{2}//'{3}'", ftpHost, ftpMainframeDSN)
ftpRequest = WebRequest.Create(ftpFullMainframePath)
ftpRequest.Credentials = New NetworkCredential(UserName, Password)
ftpRequest.KeepAlive = True
ftpRequest.UseBinary = False
ftpRequest.Method = WebRequestMethods.Ftp.UploadFile
ftpRequest.
Dim byteArray() As Byte = StrToByteArray(DataToUpload)
ftpRequest.ContentLength = byteArray.Length
Dim ftpStream As Stream = ftpRequest.GetRequestStream()
ftpStream.Write(byteArray, 0, byteArray.Length)
ftpStream.Close()
ftpStream = Nothing
ftpRequest = Nothing
End Sub