Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.9k views
in .NET FTP by
I'm trying to get a big file (several hundreds Mbyte) by FTP in C#, and if always throw System.OutOfMemoryException.
Any ides?


Thanks

3 Answers

0 votes
by (162k points)
Post a bit of code to show what you are doing. Our unit tests use about 60 MB with no problems.

I'm trying to get a big file (several hundreds Mbyte) by FTP in C#, and if always throw System.OutOfMemoryException.
Any ides?


Thanks
0 votes
by (180 points)
I know this is old but I'm hoping someone will see it and be able to help.

I've been using edtftpnet for a couple of years with no issues. We recently started sending XML as one big line of text (no CR/LF). This is fine as long as the file doesn't get too big. I have a 700MB file that shoots up to 1.4GB of memory and then throws a System.OutOfMemory exception. I've tried playing with the transferbuffer setting but I don't think it's getting that far. It never reports any bytes are transferred.

We have been able to send > 2GB files with no problems as long as it's not one big line.

Any ideas would be appreciated.

Here is my code:

_ftpClient = new FTPClient();
_ftpClient.DataEncoding = System.Text.Encoding.Default;
_ftpClient.ConnectMode = FTPConnectMode.PASV;
_ftpClient.RemoteHost = "serverName";
_ftpClient.TransferCompleteEx += _ftpClient_TransferCompleteEx;
_ftpClient.BytesTransferred += _ftpClient_BytesTransferred;

try {
_ftpClient.Connect();
_ftpClient.Login("foo", "bar");
_ftpClient.TransferType = FTPTransferType.ASCII;
_ftpClient.Put(@"C:\output\big.xml", "ftptest.xml");
}
catch (Exception ex) {
WriteLog(ex.Message);

}
0 votes
by (162k points)
The problem is that ReadLine() is used to read the source file, and that is always going to fall over if the line won't fit in memory.

Use lines or use binary transfers.

Categories

...