//发送文件
private void btn_sendFile_Click(object sender, EventArgs e)
{
//打开文件
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
//初始化接受套接字:寻址方案,以字符流方式和Tcp通信
socketSent = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
//设置服务器IP地址和端口
ipSent = new IPEndPoint(IPAddress.Parse(ip), 8001);
//与服务器进行连接
ClassSocket socketConnet = new ClassSocket(socketSent, ipSent);
Thread tConnection = new Thread(new ThreadStart(socketConnet.SocketConnect));
tConnection.Start();
Thread.Sleep(100);
//将要发送的文件加上"DAT"标识符
ClassSentFile sentFile = ne
C# Winform局域网传送文件
最新推荐文章于 2024-07-05 21:23:47 发布