Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.9k views
in .NET FTP by (160 points)
I'm using FtpConnection to do ftp processing that used to be done with scripts.
It works with FtpConnection but the operating system of the server demands that the maximum record size of the files has to be 27.
In the scripts they did this by sending the following command after connecting:

literal site mapin text(filekind=data, recordlength 27)

How can I send this with the FtpConnection class?
I tried following code but the maximum record size stays at 1:

...
ftpConnection.ServerAddress = GetFtpSetting("server");
ftpConnection.UserName = GetFtpSetting("user");
ftpConnection.Password = GetFtpSetting("password");
ftpConnection.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.ASCII;
string directory = GetFtpSetting("directory");

ftpConnection.Connect();
if (directory != "")
{
     ftpConnection.ChangeWorkingDirectory(directory);
}
ftpConnection.InvokeFTPCommand("literal site mapin text(filekind=data, recordlength 27)", null);
ftpConnection.UploadFile(strPath, strFileName, false);
ftpConnection.Close();

Any advice?

Thanks.

2 Answers

0 votes
by (51.6k points)
You were nearly right, but I think the "literal" command is a client-side command that would tell your command-line client to send whatever else you typed to the server. In other words, it would've sent "site mapin text(filekind=data, recordlength 27)" to the server.

You therefore should be using:
ftpConnection.InvokeFTPCommand("site mapin text(filekind=data, recordlength 27)", "200");

The 200 is the most common reply-code meaning that everything went well, but the server may send back something else. To see what the server returns, check what your command-line version returns and use that value.

Alternatively you can use:
ftpConnection.InvokeFTPCommand("mapin text(filekind=data, recordlength 27)");

This version implicitly does the "site" command and doesn't check the reply-code, but returns an FTPReply object for you to check yourself (if you want).

- Hans (EDT)
0 votes
by (160 points)
Thanks a lot for your help! The second solution gave an error but the first one does the trick.

I must say edtFTPnet is a very useful aid for embedding FTP inside an application. :D

Categories

...