.net
风干牛肉巴旦木
这个作者很懒,什么都没留下…
展开
-
WinForm数据绑定
实现 INotifyPropertyChangedpublic class Person : INotifyPropertyChanged{ private string name; public string Name { set { name = value; this.SendChangeInfo("Name"); } get {原创 2021-01-28 16:17:52 · 263 阅读 · 0 评论 -
C# 强制垃圾回收 GC
在需要调用垃圾回收的地方调用ClearMemory()public static void ClearMemory(){ GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1,原创 2020-11-18 16:30:55 · 1624 阅读 · 0 评论 -
C# 选择目录生成目录Treeview
/// <summary>/// 生成根目录/// </summary>/// <param name="treeView">树控件</param>/// <param name="fullPath">目录路径</param>public void CreateNodeRoot(TreeView treeView, string fullPath){ try { treeView.Nodes.原创 2020-09-29 15:47:58 · 322 阅读 · 0 评论 -
C# 注册表操作类(查询、修改、删除)
注册表操作需要获取管理员权限,可以将exe设置为管理员启动。具体操作代码如下:/// <summary>/// 注册表 HKEY_LOCAL_MACHINE/SOFTWARE 节点下/// </summary>public static class RegistryHelper{ private const string Node = "SOFTWARE"; public static string GetRegistryData(string node原创 2020-09-11 16:59:45 · 531 阅读 · 0 评论 -
C# 压缩解压文件夹 SharpZipLib/DotNetZip
1. SharpZipLib方法添加引用using ICSharpCode.SharpZipLib.Checksum;using ICSharpCode.SharpZipLib.Zip;方法/// <summary>/// 压缩多层目录/// </summary>/// <param name="strDirectory">The directory.</param>/// <param name="zipedFile">The原创 2020-09-04 15:25:17 · 1164 阅读 · 0 评论 -
Winfrom exe程序合并引用Dll
开发一些小工具exe时,会引用第三方的DLL,编译生成的exe目录下需要有这些DLL,exe无法脱离运行。1. ILMergeemmmmm, 不好使…总出错2. Costura.Fody通过Nuget安装 Costura.Fody 到需要合并的工程中 ,重启VS,重新生成项目,生成的exe与所需的Dll合并到一个exe中...原创 2020-07-28 17:11:55 · 201 阅读 · 0 评论 -
Winfrom重绘ComboBox-DropDownList样式
原生winfrom的ComboBox 样式设置为DropDownList 样式固定,且大多数重绘多为重绘下拉选择框,此代码主要重绘ComboBox的边框 背景色等。/// <summary>/// 主要为DropDownList样式重绘(特定性较强)/// </summary>public partial class EVCombobox : ComboBox{ public EVCombobox() { InitializeComponen原创 2020-07-24 17:05:00 · 853 阅读 · 0 评论 -
C# 中 Markdown文本转换为HTML语言
Markdig代码中使用如下://str:markdown文本var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();result = Markdown.ToHtml(str, pipeline);MarkDownSharp代码如下//content:markdown文本 writer:Html结果using (var reader = new StringReader(content.原创 2020-07-22 14:46:24 · 982 阅读 · 0 评论 -
C# 获取本机服务 开启关闭等
ServiceController[] Services = ServiceController.GetServices();//开启服务ServiceController ser= new ServiceController();//指定服务所在的主机名称,默认为本机,所以可以不要设置ser.MachineName = ".";ser.ServiceName = "MSSQLServer";if (ser.Status == ServiceControllerStatus.Stopped)原创 2020-05-19 15:48:50 · 277 阅读 · 0 评论 -
C# 二进制 十进制 十六进制互转
int a = 10;Console.WriteLine(a.ToString("X")); //10进制转16进制Console.WriteLine(Convert.ToString(a, 16)); //10进制转16进制Console.WriteLine(Convert.ToString(a, 2)); //10进制转2进制string b = "1010";Console.WriteLine(Convert.ToInt32(b, 2));原创 2020-05-19 15:40:43 · 138 阅读 · 0 评论 -
C# 解析HTML 四种方式
WebClient下载webpage 到本地或string中System.Net.WebClient client = new WebClient(); byte[] page = client.DownloadData("http://www.google.com"); string content = System.Text.Encoding.UTF8.GetString(page); string regex = "hre.原创 2020-05-19 15:33:28 · 7790 阅读 · 5 评论