mardi 31 mars 2015

Send file using TcpClient and NetworkStream


Vote count:

0




I have checked several examples and tutorials, but they are all different and confusing, and I couldn't figure them out completely... What I want is to send a given file from a client app to a server app, here is where I am so far


Client-side send file:



client = new TcpClient();
client.Connect(serverIP, serverPort);
byte[] file = File.ReadAllBytes(Constants.TARGET_PATH_LOGS + "squad.jpg");
byte[] fileBuffer = new byte[file.Length];
NetworkStream stream = client.GetStream();
stream.Write(file, 0, fileBuffer.GetLength(0));


Server-side receive file:



NetworkStream stream = client.GetStream();
stream.Read(???);
???


What do I need to do now in the server side to save the file properly?



asked 1 min ago







Send file using TcpClient and NetworkStream

Aucun commentaire:

Enregistrer un commentaire