FTP to Mainframe

0 votes
asked Apr 13, 2011 by hhzhu (170 points)
edited Apr 14, 2011

I'm trying to FTP to mainframe. But I got the following error message: "Name length error for pathname ftp://ps2.lac.com//'HRUNT.PER.EEF.DE34.ACK.DDATA(+1)' (550)."

What is the correct path name to use if I want to FTP to Mainframe?

Here is the code:

ftpHost = "ps2.lac.com";
ftpUserId = "testuser";
ftpPassword = "testpwd";
MainframeName = "HRUNT.PER.EEF.DE34.ACK.DDATA(+1)";

Ftp client = new Ftp();

// authenticate 
client.Login(ftpUserId, ftpPassword);

// browse directories, transfer files 
client.Site("RECFM=FB LRECL=120 BLOCKSIZE=27900");

string ftpfullpath = String.Format("ftp://{0}//'{1}'", ftpHost, MainframeName);
client.PutFile(f, ftpfullpath);

// disconnect 
Applies to: Rebex FTP/SSL

1 Answer

+1 vote
answered Apr 13, 2011 by Jan Sotola (17,670 points)
edited Apr 14, 2011

The remotePath parameter of the PutFile method is not expected to be in the full URI format (starting with "ftp://servername...").

Try to construct ftpfullpath just with the following value:

string ftpfullpath = String.Format("//'{0}'", MainframeName);


string ftpfullpath = String.Format("//{0}", MainframeName);

or only:

string ftpfullpath = String.Format("{0}", MainframeName);
commented Apr 13, 2011 by hhzhu (170 points)
edited Apr 13, 2011

string ftpfullpath = String.Format("//{0}", MainframeName); works But the file sent as binary. How do I specify the file sent as text file?

commented Apr 14, 2011 by Jan Sotola (17,670 points)
edited Apr 14, 2011

The Ftp class default transfer mode is binary. To upload file in ASCII format try setting the TransferType property to FtpTransferType.Ascii first.

For an example see http://forum.rebex.net/questions/728/sending-file-in-ascii-format