随笔分类 - C# / .NET
摘要:说明:支持跨线程访问控件。定义代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using System.Threading;...
阅读全文
摘要:最近写C#串口通信程序,系统是B/S架构。SerialPort类有一个DataReceived事件,用来接收串口返回的数据,但这种方式在C/S架构下很好用,但B/S就不好处理了。所以写了一个同步模式接收返回数据的方法,不使用DataReceived事件。经过测试,可以正常使用。 一、Machi...
阅读全文
摘要:生成验证码的类:using System;using System.Collections.Generic;using System.Drawing;using System.Text;namespace Controllers.Core.Util{ /// /// 验证码 //...
阅读全文
摘要:定义一个类:using System.Data.SQLite;namespace DAL{ /// /// SQLite中文排序 /// [SQLiteFunction(FuncType = FunctionType.Collation, Name = "PinYin")...
阅读全文
摘要:通过COM1发送数据,COM2接收数据。当COM2接收完本次发送的数据后,向COM1发送信息通知COM1本次数据已发完,COM1接到通知后,再发下一段数据。这样可以确保每次发送的数据都可以被正确接收。代码:using System;using System.Collections.Generic;u...
阅读全文
摘要:代码:using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms;namespace MyWebBrowser{ static class Program { ...
阅读全文
摘要:一、控制面板—>程序和功能—>打开或关闭Windows功能 把相关的功能勾上,点“确定”二、新建一个网站,配置ISAPI和CGI限制、处理程序映射三、CGI控制台应用程序代码:using System;using System.Collections.Generic;using System.Te...
阅读全文
摘要:代码:/// /// Http上传文件/// public static string HttpUploadFile(string url, string path){ // 设置参数 HttpWebRequest request = WebRequest.Create(url) as ...
阅读全文
摘要:代码:/// /// Http下载文件/// public static string HttpDownloadFile(string url, string path){ // 设置参数 HttpWebRequest request = WebRequest.Create(url) a...
阅读全文
摘要:首先引用ThoughtWorks.QRCode.dll代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using ThoughtWork...
阅读全文
摘要:代码:1、AES加密类using System;using System.IO;using System.Security.Cryptography;using System.Text;namespace Utils{ /// /// AES加密解密 /// public...
阅读全文
摘要:代码(该AES加密解密代码可以和Java互通): using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace Utils { /// <summary> /// AES
阅读全文
摘要:代码:using System.Data;using System.IO;using NPOI.HSSF.UserModel;using NPOI.SS.UserModel;namespace ahwildlife.Utils{ /// /// Excel工具类 /// 利用NP...
阅读全文
摘要:1、跨线程访问控件委托和类的定义using System;using System.Windows.Forms;namespace ahwildlife.Utils{ /// /// 跨线程访问控件的委托 /// public delegate void InvokeDe...
阅读全文
摘要:项目框架中有一个很实用的方法,它用来获取客户端post的数据,并自动赋值到对象各属性,这样后台少写了很多代码。但是对于有主表、子表的表单,框架中没有提供自动给子表对象各属性赋值的方法,每次都要写很多代码,各种判断,各种循环,一个属性一个属性地赋值,很不方便,所以我就尝试写了一个自动赋值的方法,用...
阅读全文
摘要:步骤: 一、前台JS取HtmlTable数据,根据设定的分隔符把数据拼接起来 <!--导出Excel--> <script type="text/javascript"> //导出Excel function exportExcel() { var data = ""; $("#divRptTabl
阅读全文
摘要:关键代码如下:/// /// 估算中英文字符串的宽度/// /// public static double GetWidthUnitCount(string value){ double count = 0; for (var i = 0; i /// 是否汉字或中文标点/// pri...
阅读全文
摘要:代码如下:/// /// 附件下载/// /// 附件IDpublic void DownloadAttach(int attachId){ Edu_Attach edu_Attach = edu_AttachService.findById(attachId); if (edu_Att...
阅读全文
摘要:使用的dll:ICSharpCode.SharpZipLib下载地址http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx/// /// 下载资料/// public void DownloadCourseData(){ ...
阅读全文
摘要:自己写的DES加密解密类,加密后生成Base64字符串,并去除'='字符。加密后替换掉'+',这样加密后的字符串可以作为url参数传递。using System;using System.IO;using System.Security.Cryptography;using System.Text;...
阅读全文

浙公网安备 33010602011771号