>I see two problems .
>(1) As you say, you keep all of the 2.2 GB in a memory stream
>(2) On top of that, you create another array of 2.2 GB and passing that to the FileStream
>
>The solution that does not take extra memory is to write loBuffer to a FileStream directly ( as opposed to loMemoryStream)
>
>Update: I do not see what the size of loBuffer is - but 4Kb to 16Kb is sufficient
>
>Update 2: using passive mode is not a bad idea
>
> ' FTP setup
>> loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI))
>> loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
>> loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
>> loFtpWebRequest.UseBinary = True
> loFtpWebRequest.UsePassive= True
>
>
>
Thanks, this has been a very productive day. This is also a very good answer.
nBuffer was 1024. I have increased it to 4096 as suggested. I do not see any difference in speed. What is advantage of using a higher buffer? If it creates less data manipulations between the client and the server, than this is good.
I adjusted the method to dump into loFileStream as suggested. This has resolved both situations. It also makes the code much simpler. The file is created as is without any additional manipulation.
What is the use of UsePassive BTW?