资源简介
C# 实现局域网文件传输与聊天程序源码,此源码为winform窗体。

代码片段和文件信息
//Download by http://www.NewXing.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
using System.Threading;
namespace send
{
public partial class Form1 : Form
{
private Thread t;
private UdpClient receivingUdpClient;
private string stFlag = null;
System.Timers.Timer timer = new System.Timers.Timer(1000);//发送UDP广播时间间隔
//System.Timers.Timer timerA = new System.Timers.Timer(1000);
private string filePathSend = null;
private string fileNameSend;
private string fileNameAccept;
private string filePathAccept = null;
private Thread fileThreadSend;
private TcpClient fileTcpClientSend;
private BinaryReader brSend=null;
private TcpListener fileListen;
private Thread fileListenThread;
private TcpClient fileClientAccept;
private Thread fileThreadAccept;
private BinaryWriter bwAccept;
private Int64 recSize = 0size=0;//接收文件大小文件本身大小
private float recFloat = 0 recFile = 0;
private float sendFloat = 0 sendFile = 0;
private bool acceptFlag = true;
private int timeFlagSend = 0;
private float sendfloat = 0acceptfloat=0;
private int timeFlagAccept = 0;
private bool sendFlag = true;
public Form1()
{
InitializeComponent();
}
//聊天中发送的实现
private void button1_Click(object sender EventArgs e)
{
int FlagChat = 0;
if (textBox2.Text==““)
{
MessageBox.Show(“消息不能为空“);
}
else
{
UdpClient udpClient = new UdpClient();
Byte[] sendBytes = Encoding.GetEncoding(“gb2312“).GetBytes(“chat“ + textBox2.Text);
ListView.CheckedListViewItemCollection checkedItemsChat =listView1.CheckedItems;
foreach (ListViewItem item in checkedItemsChat)
{
try
{
if (item.SubItems[0].Text.ToString().Equals(Dns.GetHostName().ToString() + “-本机“))
{
textBox1.Text += “您对自己说:“ + “ “ + DateTime.Now.ToString() + “\r\n“ + “ “ + textBox2.Text + “\r\n“;
}
else
textBox1.Text += “您对“ + item.SubItems[0].Text.ToString() + “说:“ + “ “ + DateTime.Now.ToString() + “\r\n“ + “ “ + textBox2.Text + “\r\n“;
udpClient.Send(sendBytes sendByt
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 901 2007-12-10 15:08 send.sln
....... 0 2007-12-11 22:35 send\bin\Debug\20071211.txt
....... 32768 2007-12-17 18:22 send\bin\Debug\send.exe
....... 38400 2007-12-17 18:22 send\bin\Debug\send.pdb
....... 5632 2005-12-08 14:51 send\bin\Debug\send.vshost.exe
....... 1 2007-12-11 12:48 send\ClassDiagram1.cd
文件 29375 2013-01-12 23:00 send\Form1.cs
文件 8910 2013-01-12 23:00 send\Form1.Designer.cs
....... 5814 2007-12-17 14:42 send\Form1.resx
....... 842 2007-12-17 14:54 send\obj\Debug\send.csproj.GenerateResource.Cache
....... 32768 2007-12-17 18:22 send\obj\Debug\send.exe
....... 180 2007-12-17 14:54 send\obj\Debug\send.Form1.resources
....... 38400 2007-12-17 18:22 send\obj\Debug\send.pdb
....... 180 2007-12-17 14:54 send\obj\Debug\send.Properties.Resources.resources
....... 247 2007-12-18 19:15 send\obj\send.csproj.FileList.txt
文件 518 2013-01-12 23:00 send\Program.cs
文件 1218 2013-01-12 23:00 send\Properties\AssemblyInfo.cs
文件 2900 2013-01-12 23:00 send\Properties\Resources.Designer.cs
....... 5612 2007-12-10 15:08 send\Properties\Resources.resx
文件 1125 2013-01-12 23:00 send\Properties\Settings.Designer.cs
....... 249 2007-12-10 15:08 send\Properties\Settings.settings
....... 3256 2007-12-11 18:30 send\send.csproj
....... 168 2007-12-11 12:50 send\send.csproj.user
目录 0 2007-12-12 23:17 send\obj\Debug\TempPE
目录 0 2007-12-17 14:54 send\bin\Debug
目录 0 2007-12-17 18:22 send\obj\Debug
目录 0 2007-12-12 23:17 send\bin
目录 0 2007-12-17 14:54 send\obj
目录 0 2007-12-12 23:17 send\Properties
目录 0 2007-12-17 18:22 send
............此处省略3个文件信息
- 上一篇:C# USB数据接收与发送
- 下一篇:摄影测量后交_前交
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论