public void SendImage() { while (true) { try { CaptureHelpers captureHelpers = new CaptureHelpers(); //获取要发送图片的路径 string url = captureHelpers.GetActiveWindowImageUrl(); using (FileStream fsRead = new FileStream(url, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[1024 * 1024 * 3]; int r = fsRead.Read(buffer, 0, buffer.Length); List <byte> list = new List <byte>(); list.Add(1); list.AddRange(buffer); byte[] newBuffer = list.ToArray(); socketSend.Send(newBuffer, 0, r + 1, SocketFlags.None); } break; } catch { } } }