Suggestions on sending Files over Network

  • Thread starter Thread starter Ebrahim
  • Start date Start date
E

Ebrahim

Does any one have any suggestion of Sending Files over a Network ?
using TcpClient class in C#.

I need suggestions on transferring huge files ( > 5MB) reliably over
the stream . Also any kind of files could have to be transferred .ie
Exe , mp3 , dat .. any kind . Do i need to convert these files ? When
i normally send text files i convert them to Ascii bytes using
Encoding.Ascii.getBytes() . Will it work with Exe files and all others
??
Pls help??
 
Hi,

There is nothing special about the file type, you are sending bytes, that's
all.

Regarding reliability TCP has already control to assure that the file is
received correctly, it all depends that the connection is stable enough to
allow the sending of the entire file.

Hope this help,
 
Generally, what you need to do is:

1) Open the network stream
2) Create a BinaryWriter on it
3) Open your source file, create a binary reader on it.
4) Repeat
* Read a chunk out of the source file
* write it over the network.

On the other end, you do something similar, except you use a BinaryReader on
the network and BinaryWriter to send the file across.



--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top