I am trying to transfer large files (5gb~50gb) on my server from to my external harddisk using windows application C#.
Code used to transfer the files:
public void CopyFile(string source, string dest)
{
using (FileStream sourceStream = new FileStream(source, FileMode.Open))
{
byte[] buffer = new byte[64 * 1024]; // Change to suitable size after testing performance
using (FileStream destStream = new FileStream(dest, FileMode.Create))
{
int i;
while ((i = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
{
destStream.Write(buffer, 0, i);
//OnProgress(sourceStream.Position, sourceStream.Length);
}
}
}
}
But the problem with this code is that when the application runs, my application would just hang there (although file still transfers at a slow speed)
Is there a better method for copying large files from the remote server?