views:

4410

answers:

10

I am trying to build an application that can request files from a service running on another machine in the network. These files can be fairly large (500mb + at times). I was looking into sending it via TCP but I'm worried that it may require that the entire file be stored in memory.

There will probably only be one client. Copying to a shared directory isn't acceptable either. The only communication required is for the client to say "gimme xyz" and the server to send it (and whatever it takes to ensure this happens correctly).

Any suggestions?

A: 

Use TransmitFile (which is a Win32 function; perhaps it's a method of the .NET library as well).

ChrisW
+2  A: 

You can use sockets in .NET to transfer files and data.

Dan
A: 

If FTP was an option then I'd go with that for the sake of simplicity. Otherwise you're into a world of TCP/IP socket programming.

Kev
+2  A: 

You might want to consider WCF streaming.

barneytron
+8  A: 

Here is an easier way. Using BITS (Background Intelligent Transfer Service). Its already built into WinXP and Vista. Its basically what drives Windows Updates.

http://blogs.msdn.com/powershell/archive/2009/01/11/transferring-large-files-using-bits.aspx

http://blogs.msdn.com/jamesfi/archive/2006/12/23/how-to-use-bits-to-transfer-files.aspx

Here is a nice managed BITS wrapper someone wrote and how to use it.

http://www.codeproject.com/KB/cs/Managed_BITS.aspx

A: 

This is a great approach if you want to show file transfer progress.

Sending Files in Chunks with MTOM Web Services and .NET 2.0

Gulzar
A: 

If files exist physically on the machine why not just put them in a folder, make that folder a virtual directory in IIS, and use Content-Based Routing and/or URL Rewriting to route the requests to them.

zvolkov
A: 

Use FTP via the open source edtFTPnet library. Fast and simple.

Bruce Blackshaw
+1  A: 

This article may help you. It is about sending large files in .NET. Check the link:

http://codetechnic.blogspot.com/2009/02/sending-large-files-over-tcpip.html

minstrel
+1  A: 

Be careful with BITS. It is a very good protocol but not a critical part of the windows update program. We found that hardly any of our corporate clients allowed the BITS update onto their machines; therefore we couldn't build an app that relied on it.

Chris Arnold