文章分类 -  c#

上一页 1 2 3 4 5 6 7 8 下一页
FTP Client library in C#
摘要:Author: Jaimon Mathew This is the C# version of an FTP client library which is originally written in Java. The library will be compiled to a DLL file. A test program is also included to show the usag... 阅读全文
posted @ 2007-05-31 14:43 石川 阅读(444) 评论(0) 推荐(0)
C# WinForm 文件上传下载
摘要:/**//// /// WebClient上传文件至服务器 /// /// 文件名,全路径格式 /// 服务器文件夹路径 private void UpLoadFile(string fileNamePath,string uriString) { //string fileName = fileNamePath.Substring(fileNamePath.LastIndex... 阅读全文
posted @ 2007-05-31 13:26 石川 阅读(1426) 评论(0) 推荐(0)
Socket与拔掉网线
摘要:当客户端与服务端通过Tcp Socket进行通信时,如果客户端应用正常退出或异常退出,服务端都会在对应的连接上获取感知(如返回0、或抛出异常)。但是,如果客户端的网线被拔掉,那么,默认情况下,服务端需要在2个小时后才会感知客户端掉线。对于很多服务端应用程序来说,这么长的反应时间是不能忍受的。 我们通常在应用层使用“心跳机制”来解决类似的问题,这是可行的。 然而,在这里,我们可以使用Sock... 阅读全文
posted @ 2007-05-30 18:17 石川 阅读(514) 评论(0) 推荐(0)
转 C# winform 文件上传
摘要:相信用ASP.NET写一个上传文件的网页,大家都会写,但是有没有人想过通过在WinForm中通过HTTP协议上传文件呢? 有些人说要向服务器端上传文件,用FTP协议不是很简单吗?效率又高,为什么还要使用HTTP协议那么麻烦呢?这里面有几个原因: (1)FTP服务器的部署相对麻烦,还要设置权限,权限设置不对,还会惹来一系列的安全问题。 (2)如果双方都还有防火墙,又不想开发FTP相关的一些端口时... 阅读全文
posted @ 2007-05-30 12:51 石川 阅读(1281) 评论(0) 推荐(0)
通过C#代码 压缩/解压文件
摘要:通过引用一DLL(ICSharpCode.dll)可以实现所述功能。。。 一、压缩文件 using System;using ICSharpCode.SharpZipLib;using ICSharpCode.SharpZipLib.Checksums;using System.IO;using ICSharpCode.SharpZipLib.Zip;using System.Collection... 阅读全文
posted @ 2007-05-29 09:30 石川 阅读(463) 评论(0) 推荐(0)
利用xpath绑定xml文件到gridview
摘要:昨天晚上赶一个任务,比较简单但是要的比较急,所以我也懒得去写太多代码,直接嗖嗖嗖拖控件,甚至连控件名都懒得去规范地重命名了。为了部署方便,我们使用了XML作为数据库。在.net里,最偷懒的办法莫过于数据直接用控件绑定,我自然别无原则。 以前没用过xml直接去绑定gridview,昨天一试,遇到了几个小问题。还好,微软的东西,只要你舍得花时间试,肯定能搞定。 (1) 建立一个xml文件... 阅读全文
posted @ 2007-05-27 09:25 石川 阅读(660) 评论(0) 推荐(0)
总结 @ 在 C# string 中的用法
摘要:1。地球人都知道 C# 中 字符串常量可以以 @ 开头声名,这样的优点是转义序列“不”被处理,按“原样”输出,即我们不需要对转义字符加上 \ (反斜扛),就可以轻松coding。如, string filePath = @"c:\Docs\Source\a.txt" // rather than "c:\\Docs\\Source\\a.txt" 2。如要在一个用 @ 引起来的字符串中包括一个双... 阅读全文
posted @ 2007-05-27 09:20 石川 阅读(597) 评论(0) 推荐(1)
Win Form中限制TextBox只能输入数字
摘要:首先引用 using System.Text.RegularExpressions;给TextBox添加KeyPress事件,代码如下: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ((Convert.ToInt32(e.KeyChar) == 8)) ... 阅读全文
posted @ 2007-05-27 09:17 石川 阅读(433) 评论(0) 推荐(0)
c#实现文件加解密
摘要:using System;using System.IO;using System.Data;using System.Text;using System.Windows.Forms;using System.Collections;using System.Collections.Generic;using System.Security.Cryptography;using System.Th... 阅读全文
posted @ 2007-05-24 20:34 石川 阅读(550) 评论(0) 推荐(0)
c# 实现MD5,SHA1,SHA256,SHA512等常用加密算法
摘要:using System;using System.IO;using System.Data;using System.Text;using System.Diagnostics;using System.Security;using System.Security.Cryptography;/**//* * .Net框架由于拥有CLR提供的丰富库支持,只需很少的代码即可实现先前使用C等旧式语言... 阅读全文
posted @ 2007-05-24 20:33 石川 阅读(1602) 评论(2) 推荐(0)
WinForm 程序中使用 Console 输出调试信息
摘要:WinForm 程序中使用 Console 输出调试信息1. 新建一个WinForm程序;2. 菜单"Project","Properties","Application",将"Output type"设置为“Console Application”;这样在运行该WinForm程序时会启动一个控制台窗口。可以使用:Console.WriteLine();Console.Write();输出调试信息... 阅读全文
posted @ 2007-05-24 15:30 石川 阅读(1053) 评论(0) 推荐(1)
C#可逆加密-Rijndael算法
摘要:CS文件: Rijndael算法//App_CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.IO;using System.Security.Cryptography;using System... 阅读全文
posted @ 2007-05-24 15:19 石川 阅读(432) 评论(0) 推荐(0)
c#导出到excel
摘要://导出Excel的方法 private void ExportExcel() { DataSet ds=dtsSelect;//数据源 if(ds==null) return; string saveFileName=""; bool fileSaved=false; SaveFileDialog saveDialog=new SaveFileDialog();... 阅读全文
posted @ 2007-05-24 13:47 石川 阅读(271) 评论(0) 推荐(0)
DataSet与二进制文件和XML文件
摘要:1.将DataSet对象序列化到二进制文件2.将二进制文件序列化到DataSet对象3.将DataSet中的数据写到XML文件4.将数据XML文件读到DataSet对象5.将DataSet中的数据及架构写到XML文件6.将数据及架构XML文件读到DataSet对象7.将DataSet中的数据及架构分别写到不同的XML文件8.将相关的数据及架构XML文件读到DataSet对象============... 阅读全文
posted @ 2007-05-22 10:59 石川 阅读(225) 评论(0) 推荐(0)
用C#打开一个pdf文件
摘要:http://www.o2sol.com/public/webui/samples.shtml 下载XpdfRasterizer.dll,XpdfRasterizerNet.dll,引用即可用 如 using XpdfRasterizerNet; protected System.Web.UI.WebControls.Button Button1... 阅读全文
posted @ 2007-05-21 08:51 石川 阅读(5323) 评论(21) 推荐(0)
指定一个文件夹,读取文件夹中的指定后缀
摘要:private void getDirectories(string path) { string[] fileNames = Directory.GetFiles("D:","*.asf"); string[] directories = Directory.GetDirectories(path); foreach (st... 阅读全文
posted @ 2007-05-21 08:42 石川 阅读(244) 评论(0) 推荐(0)
C#程序调用外部程序
摘要:** 编程语言:Visual Studio .NET C# (Beta 2)* 作 者:迪泊威* 功 能:通过C#程序调用 Windows 记事本程序 编辑一个* 名为 test.txt 的文本文件。** 在整个程序中 System.Diagnostics.Process.Start(Info) * 为主要语句。* 如果只是单独执行... 阅读全文
posted @ 2007-05-20 13:50 石川 阅读(182) 评论(0) 推荐(0)
C#中TreeView组件使用方法初步
摘要:TreeView组件是由多个类来定义的,TreeView组件是由命名空间"System.Windows.Forms"中的"TreeView"类来定义的,而其中的节点(即Node),是由命名空间"System.Windows.Forms"中的"TreeNode"来定义的。所以当在程序中创建一个TreeView对象,其实只是创建了一个可以放置节点的"容器"。而在这个容器中加入一个节点,其实就是加入了从... 阅读全文
posted @ 2007-05-20 08:51 石川 阅读(597) 评论(2) 推荐(0)
使用C#进行点对点通讯和文件传输
摘要:发送部分: 发送咱们使用了多线程,可以同时进行多个任务,比如发送文件、发送文本等,互不影响: 发送文本方法: private void StartSendText(string strHost,int iPort,string strInfo) { SendText stText = new SendText(strHost,iPort,strInfo,n... 阅读全文
posted @ 2007-05-20 08:16 石川 阅读(795) 评论(1) 推荐(0)
获取驱动器
摘要:private void Bd() { DriveInfo[] MyDrives = DriveInfo.GetDrives(); try { foreach (DriveInfo MyDrive in MyDrives) { ... 阅读全文
posted @ 2007-05-19 22:56 石川 阅读(187) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 下一页