How to send file through socket in c#

后端 未结 3 1894
再見小時候
再見小時候 2021-01-19 12:53

I have server and client console apps which communicate fine as well as sending some string. Here is the code...

Server

public static void Main()
            


        
3条回答
  •  日久生厌
    2021-01-19 13:11

    You just need to read the file in as a byte array and then send that byte array across the wire

    var bytes = File.ReadAllBytes(path);
    stm.Write(bytes , 0, bytes .Length);
    

提交回复
热议问题