Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3k views
in .NET FTP by (160 points)
Hi Hans,
I've come across edtFTPNet while looking for a free ftp software usable in my .NET codes.
This is my first day using it, and I've used FTPConnection, then FTPClient, then back to FTPConnection.
I'm having this problem on both FTPClient and FTPConnection: the Put file size is smaller than the Get file size.
To clarify matters, I'm using this great software on VMS files. I'm on a tight deadline, and I'd appreciate very much any and all help that I can get. Below are my code functions, as derived from the examples. As mentioned, for both FTPClient and FTPConnection, the results are the same. So pls, pls, pls, help me!

Thanks!
Eutychus

public static bool ftpGet(string servername, string username, string password, string filename)
{
FTPClient ftp = null;

try
{

ftp = new FTPClient(servername);

// login
ftp.Login(username, password);

// set up passive ASCII transfers
ftp.TransferType = FTPTransferType.ASCII;

// copy file from server
ftp.Get(filename, filename);

// Shut down client
ftp.Quit();

return true;
}
catch (Exception ex)
{
if (ftp.IsConnected) { ftp.Quit(); }
Console.WriteLine(ex.Message);
return false;
}
}


public static bool ftpPut(string servername, string username, string password, string filename)
{
FTPClient ftp = null;

try
{

ftp = new FTPClient(servername);

// login
ftp.Login(username, password);

// set up passive ASCII transfers
ftp.TransferType = FTPTransferType.ASCII;

// copy file to server
ftp.Put(filename, filename);

// Shut down client
ftp.Quit();

return true;
}
catch (Exception ex)
{
if (ftp.IsConnected) { ftp.Quit(); }
Console.WriteLine(ex.Message);
return false;
}
}



public static bool ftpGet2(string servername, string username, string password, string filename)
{
FTPConnection ftp = null;

try
{

ftp = new FTPConnection();
ftp.ServerAddress = servername;
ftp.UserName = username;
ftp.Password = password;
ftp.Connect();

// set up passive ASCII transfers
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;

// copy file from server
ftp.DownloadFile(filename, filename);

// Shut down client
ftp.Close();

return true;
}
catch (Exception ex)
{
if (ftp.IsConnected) { ftp.Close(); }
Console.WriteLine(ex.Message);
return false;
}
}


public static bool ftpPut2(string servername, string username, string password, string filename)
{
FTPConnection ftp = null;

try
{

ftp = new FTPConnection();
ftp.ServerAddress = servername;
ftp.UserName = username;
ftp.Password = password;
ftp.Connect();

// set up passive ASCII transfers
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;

// copy file to server
ftp.UploadFile(filename, filename);

// Shut down client
ftp.Close();

return true;
}
catch (Exception ex)
{
if (ftp.IsConnected) { ftp.Close(); }
Console.WriteLine(ex.Message);
return false;
}
}

3 Answers

0 votes
by (162k points)
If you are transferring in ASCII mode it is quite likely that the file sizes will differ, especially transferring from VMS. The line terminators are translated between the client and server operating systems.
0 votes
by (160 points)
Thank you for your reply. Now the problem is sort of confirmed. Is there no solution to this? Would appreciate really if there is. Again, thanks for the support, and the great software.

Eutychus
0 votes
by (162k points)
I'm not sure what the problem is - the same text file on different platforms (e.g. Unix vs Windows) is different sizes.

If you want the exact file transferred including line terminators, use binary mode transfer.

Categories

...