メインフレームにローカルファイルをFTPする必要があり、ストリームライタを使用してローカルバッチテキストファイルを作成し、 -s:それを実行するコマンド。VB FTPコードはデバッグ(F10)で動作しますが、実行時またはF5で動作しません
ここにコードがあります。
Shared Sub TestFTP()
' BP DEFINED INPUTS ANDF OUTPUTS
'Inputs
Dim hostname As String
Dim username As String
Dim password As String
Dim mainfile As String
Dim localfile As String
'Outputs
Dim success As Boolean
Dim message As String
'-------------
'Test DATA
'-------------
hostname = "XXIBM2"
username = "USER1"
password = "XXX1234"
mainfile = "XXTSO.USER1.TEST2"
localfile = "D:\TestFTP.txt"
'=============================BP Code========================
Try
Dim localPath As String = "C:\BPFTP"
Dim isExists As Boolean = System.IO.Directory.Exists(localPath)
If (isExists = False) Then
System.IO.Directory.CreateDirectory(localPath)
End If
' Open StreamWriter And create batch file
Using writer As StreamWriter = New StreamWriter(localPath + "\\FTP.txt")
writer.WriteLine("open " + hostname)
writer.WriteLine(username)
writer.WriteLine(password)
writer.WriteLine("put " + localfile + " '" + mainfile + "'")
writer.WriteLine("bye")
writer.WriteLine("exit")
End Using
' Perform FTP
Interaction.Shell("ftp -n -s:C:\BPFTP\FTP.txt")
' Delete batch file
System.IO.File.Delete("C:\\BPFTP\\FTP.txt")
success = True
Catch e As Exception
success = False
message = e.Message
End Try
End Sub
F5キーを使用してコードを実行すると、メインフレームにファイルが表示されません。
シェルコマンドでブレークポイングを設定し、コード(f5)をここに、次にF5を最後まで実行すると、ファイルはメインフレームにFTPdを取得しません。
ブレークポイントにコードを実行し、F10キーを使用してShellコマンドラインを単にステップオーバーすると、ファイルは正常にメインフレームにFTP転送されます。
あなたは何を意味するのかわかりませんが、私には管理者権限があります。ジミー・スミスは以下の問題の解決法を提供しました。 – RobT