阚金翔
达则兼济天下,穷则独善其身

随笔分类 -  朝花夕拾

早上的花虽然已凋零, 但在黄昏时仍能拾起来, 给人们已有意义。
【C#6.0的常用特性】可空表达式和模板字符串
摘要:可空表达式 可空表达式只能是 C# 6.0+ 才可以使用,VS2015+ 版本才支持 在这个表达式出现之前,当我们得到一个对象时,并想要使用这个对象之前,都必须先判断该对象是否为 null,否则使用对象时就会抛出 NullReferenceException 异常(未将对象引用设置到对象的实例)。 阅读全文
posted @ 2020-06-19 15:43 阚金翔 阅读(745) 评论(0) 推荐(0) 编辑
随机数
摘要:Random rd = new Random(); int random = rd.Next(1000, 1000000); string str = random.ToString(); 创建于2017年1月19日 整理于2017年12月1日 阅读全文
posted @ 2017-12-01 10:20 阚金翔 阅读(153) 评论(0) 推荐(0) 编辑
通过注册表修改IE浏览器内核版本
摘要:static public void SetIERegistry() { try { //获取系统IE版本号 string strIEVersion = SysIeVersion(); if (string.IsNullOrEmpty(strIEVersion) || strIEVersion.Sp 阅读全文
posted @ 2017-11-30 16:14 阚金翔 阅读(3284) 评论(0) 推荐(0) 编辑
通过Process运行bat脚本文件
摘要:Process proc = null; try { proc = new Process(); proc.StartInfo.FileName = @"C:\Users\Administrator\Desktop\script"; proc.StartInfo.Arguments = string 阅读全文
posted @ 2017-11-30 16:02 阚金翔 阅读(1118) 评论(0) 推荐(0) 编辑
窗体抖动
摘要://实现窗体抖动的效果 Point first = this.Location; for (int i = 0; i < 30; i++) { Random ran = new Random(); Point p = new Point(this.Location.X + ran.Next(10) 阅读全文
posted @ 2017-11-30 13:38 阚金翔 阅读(186) 评论(0) 推荐(0) 编辑
OpenFileDialog和SaveFileDialog的简单使用
摘要://文件名 private string curFileName; //图像对象1 private Bitmap curBitmap; //将本地图片保存到pictureBox中 private void button1_Click(object sender, EventArgs e) { Ope 阅读全文
posted @ 2017-11-29 14:57 阚金翔 阅读(1193) 评论(0) 推荐(0) 编辑
屏幕截屏
摘要://获得当前屏幕的分辨率 Rectangle rc = sc.Bounds; int iWidth = rc.Width; int iHeight = rc.Height; //创建一个和屏幕一样大的Bitmap Bitmap myImage = new Bitmap(iWidth, iHeight 阅读全文
posted @ 2017-11-29 14:37 阚金翔 阅读(171) 评论(0) 推荐(0) 编辑
通过注册表实现开机自启的取消
摘要:一、添加引用 using Microsoft.Win32;//添加的引用 二、开启和关闭的方法 string path = Application.ExecutablePath; RegistryKey rk = Registry.LocalMachine; RegistryKey rk2 = rk 阅读全文
posted @ 2017-11-28 17:26 阚金翔 阅读(739) 评论(0) 推荐(0) 编辑
判断字符串是否为空的几种方法
摘要:string str = string.Empty;if (str == ""){ }else { } if (str == string.Empty){ }else { } if (str.Length == 0)//效率最高{ }else { } if (string.IsNullOrEmpty 阅读全文
posted @ 2017-11-28 09:21 阚金翔 阅读(2255) 评论(0) 推荐(0) 编辑
重命名文件
摘要:Computer MyComputer = new Computer();MyComputer.FileSystem.RenameFile(FileName, newFileName);//其中FileName是你所要重命名的文件的全路径,newFileName仅仅是目标文件名。 创建于2017年2 阅读全文
posted @ 2017-11-28 09:20 阚金翔 阅读(130) 评论(0) 推荐(0) 编辑