Answer the question
In order to leave comments, you need to log in
How to transfer multiple large files over TCP using .NET?
Hello. I need to write a program that will send video files to given addresses. Since the files must arrive intact, it was decided to use the TCP protocol. At the moment I'm doing something like this:
_server.Connect(endPoint);
_server.SendFile(filePath);
_server.Close();
using (FileStream fs = new FileStream(
@$"D:\Repositories\VideoSenderClient\VideoSenderClient\ReceivedFiles\{System.Guid.NewGuid()}.txt",
FileMode.Create))
{
NetworkStream ns = new NetworkStream(handler);
while (handler.Available > 0)
{
ns.Read(buffer, 0, buffer.Length);
fs.Write(buffer);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question