FtpWebRequest连接到AS/400 [英] FtpWebRequest Connecting to an AS/400

查看:142
本文介绍了FtpWebRequest连接到AS/400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从旧的AS/400服务器通过ftp下载一些文件.我的代码或多或少像:

I need to download some files via ftp from an old AS/400 server. My code looks more or less like:

FtpWebRequest _request = (FtpWebRequest)WebRequest.Create("ftp://ftpaddress/FOO.CSV");
_request.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
_request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = (FtpWebResponse)_request.GetResponse();

但是,该消息引发了异常:

However, an exception is being thrown with the message:

501 Character (/) not allowed in object name.

我猜AS400使用的路径分隔符不同于/,但是我不知道如何用(1)FtpWebRequest接受和(2)AS400可以理解的方式来表示uri.

I'm guessing the AS400 uses a different path separator than / but I can't figure out how to phrase the uri in a way (1) FtpWebRequest accepts and (2) the AS400 understands.

还有其他人碰到这个吗?

Anyone else bumped into this?

推荐答案

我过去经常收到此消息,这意味着我忘记更改名称格式.

I've had this message often in the past, and it meant that I forgot to change the name format.

使用AS400进行FTP时,可以使用两种名称格式,可以使用FTP命令NAMEFMT进行更改:

There are two name formats possible when doing FTP with an AS400, and it can be changed with the FTP command NAMEFMT:

0用于库系统文件(library \ filename.member)

0 is for the library system files (library\filename.member)

1用于IFS中的文件,CSV文件在其中

1 is for the files in the IFS, where a CSV file would be

默认情况下,它设置为0.

By default, it is set to 0.

将其更改为1,它应该可以工作.但是我不确定如何使用FtpWebRequest进行更改.

Change it to 1 and it should work. However I'm not sure how it can be changed with a FtpWebRequest.

这篇关于FtpWebRequest连接到AS/400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆