易截截图软件、单文件、免安装、纯绿色、仅160KB

C#的TCP通信


TCP是连接模型,如下:
服务器连接                     服务器断开
    ↓                                   ↑
服务器接收→服务器处理→服务器发送
    ↑                                   ↓
客户端发送←客户端处理←客户端接收
    ↑                                   ↓
客户端连接                     客户端断开
服务器代码如下:
//
ServerListen
TcpListener tcplistener
=
new
 TcpListener(
int
.Parse(txtPort.Text));
tcplistener.Start();
byte
[] btServerReceive
=
new
 
byte
[
256
];
string
 strServerReceive
=
string
.Empty;
//
Loop for Listen
while
(
true
)
{
 TcpClient tcp
=
tcplistener.AcceptTcpClient();
 NetworkStream ns
=
tcp.GetStream();
 
int
 intReceiveLength
=
 ns.Read(btServerReceive,
0
,btServerReceive.Length);
 strServerReceive
=
UnicodeEncoding.Unicode.GetString(btServerReceive,
0
,intReceiveLength);
 txtServerResult.AppendText(
"
ServerReceive:
"
 
+
 strServerReceive
+
"

"
);
 ns.Write(btServerReceive,
0
,btServerReceive.Length);
 txtServerResult.AppendText(
"
ServerSend:
"
&


相关文档:

C# 通过xsl转换大xml文件方法

通过xsl转换大xml文件
这几天在做这个,网上的几个方法我都试过了,汇总如下
方法一:
XPathDocument myXPathDoc = new XPathDocument(tbXMLFile.Text);
 
XslCompiledTransform myXslTrans = new XslCompiledTransform();
myXslTrans.Load(tbXSLFile.Text);
 
XmlTextWriter myWriter = new XmlTextWrit ......

C#使用SQLDMO实现对MSSQL数据库进行备份和恢复

public sealed class DbOper
{
     ///<summary>
     /// DbOper类的构造函数
     ///</summary>
     private DbOper()
     {
     }
     ......

C#开机自动启动应用程序

//命名空间 using Microsoft.Win32;
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox2.Checked) //设置开机自启动
{
//MessageBox.Show ("设置开机自启动需要修改注册表","提示");
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMac ......

c#中一个窗体调用另一个窗体的控件及方法(转贴)

参考资料:http://wenwen.soso.com/z/q39607884.htm
如何在一个窗体中调用另一个窗体的控件或方法
答案是从构造函数中传递参数。
要把Form1中的控间改成public属性
具体实现过程请参看一下代码(在form2的textbox1中输入然后在form1中的label1中显示textbox中的内容
//form1代码,form1中有一个label1和一个button1,其 ......

C# 图片裁剪

/// <summary>
/// 缩小裁剪图片
/// </summary>
/// <param name="int_Width">要缩小裁剪图片宽度</param>
/// <param name="int_Height">要缩小裁剪图片长度</param>
/// <param name="input_ImgUrl">要处理图片路径< ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号