镹丶天
好男儿当志在天下,好男儿亦不负红颜!
展开
-
实现http文件下载和上传
实现http文件下载 static void Main(string[] args) { string url = ""; string path = ""; // 设置参数 HttpWebRequest request = WebRequest.Create(url) as原创 2016-12-03 15:20:44 · 472 阅读 · 0 评论 -
C#中的文件读写
C#中的文件读写一、递归删除文件夹目录和文件/**************************************** * 函数名称:DeleteFolder * 功能说明:递归删除文件夹目录及文件 * 参 数:dir:文件夹路径 * 调用示列: * string dir = Server.MapPath("test/"); *原创 2016-12-03 15:12:44 · 335 阅读 · 0 评论 -
判断当前是DEBUG还是Release构建
判断当前是DEBUG还是Release构建/// <summary>/// 判断当前运行模式/// </summary>public bool IsDebug{ get { #if (DEBUG) return false; #else return true; #endif原创 2016-12-03 15:08:40 · 2124 阅读 · 0 评论 -
使用 Microsoft.Win32.RegistryKey读写注册表
使用 Microsoft.Win32.RegistryKey读写注册表//添加当前程序为开机启动项 string path = Application.ExecutablePath; Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine; M原创 2016-12-03 15:07:38 · 2785 阅读 · 0 评论 -
C#中的序列化
什么是序列化?System.Runtime.Serizlization 命名空间中实现了序列化的技术,序列化是将对象转换成线性字节,以便进行存储和传输,而反序列化是将序列化之后的有序字段转换成对象。如何序列化一个对象?1.创建一个流对象来保存序列化后的输出。2.创建BinaryFormatter对象(位于:System.Runtimes.Serialization.Formatters.Bina原创 2016-12-03 16:28:35 · 413 阅读 · 0 评论 -
InI文件工具类
直接上代码理解:ini文件格式;这里以分号开头的都是注释[section]xxx=valueusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Web;using System.Runtime.InteropServices;using Syste原创 2017-01-16 19:32:09 · 460 阅读 · 0 评论 -
INI文件读写
废话不多说 直接切入主题上代码using System;using System.Collections.Generic;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;namespace DemoFiles{ /// <s原创 2016-12-03 15:46:20 · 309 阅读 · 0 评论 -
C#验证代理Ip地址
码上来了?命名空间: using System.Net; using System.Text; /// <summary> /// 验证IP地址 /// </summary> /// <param name="str">Ip地址</param> /// <param name="port">端口号</param>原创 2017-02-10 18:07:39 · 913 阅读 · 0 评论 -
Winfrom异步更新UI
UI控件的Invoke/BegainInvoke方法更新#region 异步更新UI delegate void SetTextCallback(string text); /// <summary> /// 点击按钮事件 /// </summary> /// <param name="sender"></param>原创 2017-05-10 23:01:40 · 1381 阅读 · 0 评论 -
C# 多线程随手记
直接上代码 /// <summary> /// 执行多线程方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnThread_Click(object sender,原创 2017-05-10 23:24:19 · 256 阅读 · 0 评论 -
获取公网IP地址
获取,本机、与公网IP地址using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Threading.Tasks;namespace MailMsg{ public class原创 2016-12-03 15:03:07 · 338 阅读 · 0 评论 -
C# WinForm 拖动无边框窗体
首先添加可拖动区域先拖一个panel(name=panel1)再在panel1上拖动一个label上面写上”可拖动区域”。 然后在Form1.cs中添加以下代码: [csharp] view plain copy print? //定义无边框窗体Form [DllImport(“user32.dll”)]//***********拖动无窗体的控件 public static extern转载 2017-06-23 09:53:40 · 549 阅读 · 0 评论 -
.Net中正则表达式
使用正则表达式获取网页编码 Match charSetMatch = System.Text.RegularExpressions .Regex.Match(content, "<meta([^<]*)charset=([^<]*)\"", RegexOptions.IgnoreCase | RegexOptions.Multi原创 2016-12-03 16:02:41 · 354 阅读 · 0 评论 -
C#使用反射将DataTable转换List<T>
直接上干货/// <summary> /// DataTable转换为List /// </summary> public static class ToList { public static IList<T> ToLists<T>(this DataTable table) { if (table == nu原创 2016-12-04 01:13:50 · 1657 阅读 · 0 评论 -
C# WindowsAPI
**Windows是一个强大的操作系统,也会向开发者提供海量的系统API来帮助开发者来完成Windows系统软件的开发工作。整理的部分Windows API,C#可以直接调用**1.获取.exe应用程序的图标[DllImport("shell32.DLL", EntryPoint = "ExtractAssociatedIcon")] private static extern int Extr原创 2016-12-03 18:05:30 · 579 阅读 · 1 评论 -
C#Path路径处理
常用路径 //获取当前程序路径,包括文件名 string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //获取应用程序的当前工作目录。 string str3 = System.IO.Director原创 2016-12-03 15:39:12 · 882 阅读 · 0 评论 -
.NET日期时间处理
时间日期1.DateTime.ParseExact很多时候我们获取的时间是数字形式表示的,好比20140127134015.927856,通过这个方法DateTime.ParseExact("20140127134015.927856", "yyyyMMddHHmmss.ffffff", null);就会得到正确的时间格式数据。2.Guid数据常见的是 10244798-9a34-4245-b1e原创 2016-12-03 15:51:09 · 423 阅读 · 0 评论 -
.NET中的Process 类的简单使用
废话不多写,直接来干货。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Drawing;using System.IO;using System.Linq;using Sys原创 2016-12-03 15:55:19 · 993 阅读 · 0 评论 -
NLog日志记录学习
配置NLog NLog支持 .Net 4.5 以及以上版本! 首先去下载NLog的DLL下载地址:http://nlog-project.org/download/ 然后把下载下来的Nlog.dll ,Nlog,extension.dll 加入项目reference.之后就是配置NLog.config 格式如下: 通过在启动的时候对一些常用目录的扫描,NLog会尝试使用找到的配原创 2016-12-03 15:57:48 · 520 阅读 · 0 评论 -
C#中的字符串操作
字符串转换大小写 //将所有字符串转换为大写 string strToLower = "EEKLASJDLAJLDSAJLD".ToLower(); //将所有字符串转换为小写 string strToUpper = "EEKLASJDLAJLDSAJLD".ToUpper();字符串替换string webContent = webEndig.GetString(webData);webC原创 2016-12-03 16:06:20 · 356 阅读 · 0 评论 -
C#中显现串口通信SerialPort类
使用SerialPort类的方法:首先要添加1.在类的内部定义SerialPort com;2.打开串口 using System.IO; using System.IO.Ports; com = new SerialPort(); com.BaudRate = 115200; com.PortName = "C原创 2016-12-03 16:15:52 · 1010 阅读 · 0 评论 -
使用C#邮件发送需要邮箱开通smtp功能
设置右键服务器地址 string senderServerIp = "123.125.50.133";//smtp.163.com发件箱的邮件服务器地址 //string senderServerIp = "74.125.127.109"; //smtp.gmail.com发件箱的邮件服务器地址 //string senderServerIp =原创 2016-12-03 16:17:32 · 1815 阅读 · 0 评论 -
C#中的反射
反射(Reflection)是.NET中的重要机制,通过放射,可以在运行时获得.NET中每一个类型(包括类、结构、委托、接口和枚举等)的成员,包括方法、属性、事件,以及构造函数等。还可以获得每个成员的名称、限定符和参数等。有了反射,即可对每一个类型了如指掌。如果获得了构造函数的信息,即可直接创建对象,即使这个对象的类型在编译时还不知道。 1.加载程序集: /// <summary>原创 2016-12-03 16:21:28 · 279 阅读 · 0 评论 -
.Net应用程序域
一、什么是应用程序域?应用程序域是一个逻辑容器,它允许多个程序集在同一个进程内进行,但会组织它们直接访问属于其他程序的内存,此外应用程序域还提供了错误隔离机制,这是因为未处理的异常不会影响到其他应用程序域。所以在其他应用程序域的应用程序可以不受干扰地继续运行!使用应用程序域有什么好处?1.应用程序域的优势在于,每个应用程序都可以分配一个不同的安全访问级别,(即使它和其他应用程序域都运行在一个进程中原创 2016-12-03 16:24:12 · 758 阅读 · 0 评论 -
.NET中的单元测试
1.单元测试任务包括(1)、输入的实际参数与形式参数的个数是否相同; (2)、输入的实际参数与形式参数的属性是否匹配; (3)、输入的实际参数与形式参数的量纲是否一致; (4)、调用其他模块时所给实际参数的个数是否与被调模块的形参个数相同; (5)、调用其他模块时所给实际参数的属性是否与被调模块的形参属性匹配; (6)、调用其他模块时所给实际参数的量纲是否与被调模块的形参量纲一致; (7原创 2016-12-03 16:31:44 · 446 阅读 · 0 评论 -
ASP.NET MVC笔记
asp.net mvc 请求路径: 服务器地址/控制器名称/控制器方法名 路由配置:url = controller / action / id public class RouteConfig{ public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreR原创 2016-12-03 16:52:15 · 295 阅读 · 0 评论 -
C#读写XML文件
使用Configuration读取xml文件XML文件格式<appSettings> <add key="WebPath" value="http://www.baidu.com"/></appSettings>读取:System.Configuration.ConfigurationManager.AppSettings["WebPath"];xml文件<?xml version="1.0"原创 2016-12-03 17:19:51 · 561 阅读 · 0 评论 -
封装一个生成分页SQL
/// <summary> /// 查询分页 /// </summary> /// <param name="sql">查询语句</param> /// <param name="pageCount">每页显示条</param> /// <param name="pageNumber">页数</param>原创 2017-01-03 09:22:46 · 694 阅读 · 0 评论