从 VB.net 将文件上传到大型机

发布于 2024-08-08 19:51:34 字数 1344 浏览 4 评论 0原文

我正在尝试将文件从我的电脑上传到大型机。我正在尝试使用 Chilkat FTP2 上传它。下面是代码。

我尝试上传的文件是 2009102600000

Dim ftp As New Chilkat.Ftp2()

Dim success As Boolean

' Any string unlocks the component for the 1st 30-days.'
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


ftp.Hostname = "www.myside.com"
ftp.Username = "****"
ftp.Password = "****"

' The default data transfer mode is "Active" as opposed to "Passive".'
' Change it to Passive by setting the Passive property:'
ftp.Passive = true

' Connect and login to the FTP server.'
success = ftp.Connect()
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


' Change to the remote directory where the file will be uploaded.'
success = ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


' Upload a file.'
Dim localFilename As String
localFilename = "c:\2009102600000"
Dim remoteFilename As String
remoteFilename = "2009102600000"

success = ftp.PutFile(localFilename,remoteFilename)
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


ftp.Disconnect()

MsgBox("File Uploaded!")

我收到的错误是找不到数据集,使用 MVS dsn 名称或类似名称。

如果您能帮我解决这个问题,我将不胜感激。

I am trying to upload a file from my pc to mainframes. I am trying to upload it using Chilkat FTP2. Below is the code.

The file I am trying to upload is 2009102600000

Dim ftp As New Chilkat.Ftp2()

Dim success As Boolean

' Any string unlocks the component for the 1st 30-days.'
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


ftp.Hostname = "www.myside.com"
ftp.Username = "****"
ftp.Password = "****"

' The default data transfer mode is "Active" as opposed to "Passive".'
' Change it to Passive by setting the Passive property:'
ftp.Passive = true

' Connect and login to the FTP server.'
success = ftp.Connect()
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


' Change to the remote directory where the file will be uploaded.'
success = ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


' Upload a file.'
Dim localFilename As String
localFilename = "c:\2009102600000"
Dim remoteFilename As String
remoteFilename = "2009102600000"

success = ftp.PutFile(localFilename,remoteFilename)
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


ftp.Disconnect()

MsgBox("File Uploaded!")

The error I am getting is dataset not found use MVS dsn name or something like that.

I would really appreciate if you can help me out with this one please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半窗疏影 2024-08-15 19:51:34

我完全不确定您是否可以将数据集前缀视为目录。当我使用 ftp 上传到大型机时,我总是只指定完整的目标名称。我将完全删除该

ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")

部分,只需将:更改

remoteFilename = "2009102600000"

为:

remoteFilename = "'ABC.SITEUPLOAD.UPLOAD.2009102600000'"

如果它是顺序数据集,或者:

remoteFilename = "'ABC.SITEUPLOAD.UPLOAD(2009102600000)'"

如果它是成员(在这种情况下,数据集必须首先存在)。

如果您更改 MsgBox 语句,使其包含有关实际导致错误的原因的指示,也会有所帮助。大致如下:

MsgBox("Connect error: " & ftp.LastErrorText)
MsgBox("ChangeRemoteDir error: " & ftp.LastErrorText)
MsgBox("PutFile error: " & ftp.LastErrorText)

而不是通用的:

MsgBox(ftp.LastErrorText)

另一点:您会注意到我在上面的目标周围加了单引号。这是因为 z/OS 习惯(有时)为成员添加登录名前缀。可能是:

put xyz.txt upload(xyz)

实际上正在尝试将其放入 yourname.upload(xyz) 中。引用它可以防止这种情况发生。

更新:你知道,我刚刚注意到一些在我第一次读到这个问题时完全没有注意到的事情。错误消息清楚地说明了这一点。

分区数据集中的数据集名称段和成员名称限制为 8 个字符。因此,您的 'ABC.SITEUPLOAD.UPLOAD(2009102600000)'SITEUPLOAD2009102600000 两个计数中无效>。尝试缩短名称并重新传输。

证明如下:

C:\Documents and Settings\Pax> ftp bigiron
Connected to bigiron.box.com.
220-FTPD1 IBM FTP CS V1R9 at BIGIRON.BOX.COM, 02:15:23 on 2009-11-06.
220 Connection will close if idle for more than 5 minutes.
User (bigiron.box.com:(none)): pax
331 Send password please.
Password:
230 PAX is logged on.  Working directory is "PAX.".

ftp> put test.txt 'pax.siteupload'
200 Port request OK.
501 Invalid data set name "'pax.siteupload'".  Use MVS Dsname conventions.

ftp> put test.txt 'pax.siteupld'
200 Port request OK.
125 Storing data set PAX.SITEUPLD
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.

ftp> put test.txt 'pax.jcl(abcdefghi)'
200 Port request OK.
501 Invalid data set name "'pax.jcl(abcdefghi)'".  Use MVS Dsname conventions.

ftp> put test.txt 'pax.jcl(abcdefgh)'
200 Port request OK.
125 Storing data set PAX.JCL(ABCDEFGH)
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.

ftp> bye
221 Quit command received. Goodbye.

I'm not at all sure you can treat data set prefixes as directories. When I'm doing uploads to the mainframe with ftp, I always just specify the full target name. I would get rid of the

ftp.ChangeRemoteDir("ABC.SITEUPLOAD.UPLOAD")

section altogether and just change:

remoteFilename = "2009102600000"

to:

remoteFilename = "'ABC.SITEUPLOAD.UPLOAD.2009102600000'"

if it's a sequesntial data set, or:

remoteFilename = "'ABC.SITEUPLOAD.UPLOAD(2009102600000)'"

if it's a member (in which case the data set will have to exist first).

It would also help if you changed the MsgBox statements so that they included an indication as to what is actually causing the error. Something along the lines of:

MsgBox("Connect error: " & ftp.LastErrorText)
MsgBox("ChangeRemoteDir error: " & ftp.LastErrorText)
MsgBox("PutFile error: " & ftp.LastErrorText)

instead of the generic:

MsgBox(ftp.LastErrorText)

One other point: you'll notice I've put single quotes around the targets above. That's because z/OS has a habit of (sometimes) prefixing your login name to members. It may be that:

put xyz.txt upload(xyz)

is actually trying to put it into yourname.upload(xyz). Quoting it will prevent that.

Update: You know, I just noticed something that totally escaped me the first time I read this question. The error message spells it out plainly.

Data set name segments and member names within partitioned data sets are limited to 8 characters. Hence your 'ABC.SITEUPLOAD.UPLOAD(2009102600000)' is invalid on two counts, the SITEUPLOAD and the 2009102600000. Try shortening the names and re-transferring.

Here's the proof:

C:\Documents and Settings\Pax> ftp bigiron
Connected to bigiron.box.com.
220-FTPD1 IBM FTP CS V1R9 at BIGIRON.BOX.COM, 02:15:23 on 2009-11-06.
220 Connection will close if idle for more than 5 minutes.
User (bigiron.box.com:(none)): pax
331 Send password please.
Password:
230 PAX is logged on.  Working directory is "PAX.".

ftp> put test.txt 'pax.siteupload'
200 Port request OK.
501 Invalid data set name "'pax.siteupload'".  Use MVS Dsname conventions.

ftp> put test.txt 'pax.siteupld'
200 Port request OK.
125 Storing data set PAX.SITEUPLD
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.

ftp> put test.txt 'pax.jcl(abcdefghi)'
200 Port request OK.
501 Invalid data set name "'pax.jcl(abcdefghi)'".  Use MVS Dsname conventions.

ftp> put test.txt 'pax.jcl(abcdefgh)'
200 Port request OK.
125 Storing data set PAX.JCL(ABCDEFGH)
250 Transfer completed successfully.
ftp: 177 bytes sent in 0.00Seconds 177000.00Kbytes/sec.

ftp> bye
221 Quit command received. Goodbye.
两仪 2024-08-15 19:51:34

您确定不需要将其存储为根目录中的世代数据集吗?像这样:

'ABC.SITEUPLOAD.UPLOAD.2009102600000(+1)'

Are you sure you don't need to store it as a generational dataset from the root directory? Like this:

'ABC.SITEUPLOAD.UPLOAD.2009102600000(+1)'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文