随笔分类 - C# / .NET
摘要:代码: ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.B
阅读全文
摘要:以前写抓取网页的代码喜欢用ReadToEnd,因为简单省事,后来发现,在爬取网页的时候,如果网速很慢,ReadToEnd超时的几率很大。使用Read改写后,超时几率大大减小,完整代码如下: /// <summary> /// HttpPost /// </summary> public static
阅读全文
摘要:写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我 1、HttpUtil工具类,用于模拟用户登录以及爬取网页: using System; using System.Collections.Generic; using System.IO; using
阅读全文
摘要:代码: using System; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; using System.Net; using
阅读全文
摘要:示例代码: PT_USER_INFO user = new PT_USER_INFO(); IList<TES_COMBAT_TASK> taskList = new List<TES_COMBAT_TASK>(); BackgroundWorker worker = new BackgroundW
阅读全文
摘要:代码: private string GetImageExtension(MemoryStream ms) { try { Image image = Image.FromStream(ms); if (image.RawFormat.Guid == ImageFormat.Bmp.Guid) re
阅读全文
摘要:工具类代码: using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using Syste
阅读全文
摘要:代码: using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.
阅读全文
摘要:代码: private void button5_Click(object sender, EventArgs e) { int val = 5; Task.Factory.StartNew(() => { MessageBox.Show("测试StartNew:无参数"); }); Task.Fa
阅读全文
摘要:代码: /// <summary> /// 添加普通偏转角度文字水印 /// </summary> public static void SetWatermark(string filePath, string text) { PdfReader pdfReader = null; PdfStamp
阅读全文
摘要:设计界面: 控件代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; u
阅读全文
摘要:Socket封装,支持多客户端,支持大文件传输,支持多线程并发,对较大的Socket包进行分块传输。 封装所要达到的效果,是可以像下面这样使用Socket和服务端通信,调用服务端的方法,让你在使用Socket的时候,感觉不到Socket的存在,就像是调用本地方法一样,并且支持ref参数和out参数:
阅读全文
摘要:1、页面后台代码添加如下属性: /// <summary> /// 总数 /// </summary> private double total { set { Session["DPMS.POP.POP_ExcelLeadIn_total"] = value; } get { if (Sessio
阅读全文
摘要:1、匹配a标签及其url: 说明:在上面的正则表达式中, 用来匹配href属性前面和后面的各种属性: 用来匹配href属性引号中间的url: 用来匹配a标签之间的内容: 2、匹配img标签及其url: 3、匹配标签及标签中间的内容: 或: 说明:当html字符串如下时,可以匹配到两处, 如果正则表达
阅读全文
摘要:代码: #region 解压 /// <summary> /// 解压 /// </summary> public void UnZip(string zipPath, string targetPath) { using (FileStream fsZip = new FileStream(zip
阅读全文
摘要:HTTP请求工具类(功能:1、获取网页html;2、下载网络图片;): using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using Sy
阅读全文
摘要:需求:1、点击“关闭”按钮时,程序最小化到托盘,并没有退出,这时再次运行程序,不会重复运行,而是显示已运行的程序;2、支持不同目录;3、支持修改名称。 代码(不支持修改名称,不支持不同目录): using System; using System.Collections.Generic; using
阅读全文
摘要:代码:using System;using System.Collections.Generic;using System.Linq;using System.Security.Cryptography;using System.Text;using System.Threading.Tasks;n...
阅读全文
摘要:代码:using System;using System.Collections.Generic;using System.Configuration;using System.Linq;using System.Net.Mail;using System.Text;namespace Common...
阅读全文
摘要:MachineJP类: 第1部分:串口初始化,串口数据读写 using System; using System.Collections.Generic; using System.IO.Ports; using System.Linq; using System.Text; using Syste
阅读全文

浙公网安备 33010602011771号