
c#
文章平均质量分 85
天蒙蒙亮
这个作者很懒,什么都没留下…
展开
-
C#中判断传入字符串为纯数字类型的
using System; namespace ConsoleApplication1{ class Program { static void Main(string[] args) { string s = "122.2";转载 2017-12-19 17:31:34 · 1298 阅读 · 0 评论 -
C#控制台代码获取windows的关机事件。
//将该出发语句放main方法下,触发。SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding); private static void SystemEvents_SessionEnding(object sender, SessionEndingEventA转载 2018-01-02 16:23:52 · 1703 阅读 · 1 评论 -
c# http协议上传文件+传输数数据
using System;using System.Collections.Generic;using System.Collections.Specialized;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Threading.Tasks;原创 2017-12-27 23:09:42 · 5053 阅读 · 3 评论 -
C# 获取文件名和扩展名(后缀名)
string fullPath = @"d:\test\default.avi";string filename = Path.GetFileName(fullPath);//返回带扩展名的文件名 "default.avi"string extension = Path.GetExtension(fullPath);//扩展名 ".aspx"string file转载 2017-12-26 09:30:29 · 16718 阅读 · 0 评论 -
c# Timer 定时任务
一、 定时任务using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Timers; namespace ConsoleApplication3 { class Program原创 2017-12-12 11:35:07 · 1529 阅读 · 0 评论 -
c# 程序一直运行着,CPU占用率高的问题。
请教 c# 程序CPU占用率高的问题。近日我也在写一个定时采集数据传递到服务器的工具,需要一直运行着,后台用一个线程每隔2秒就判断一次时间,是否到了设定的传输时间,到了点就传送。(System.Threading.Thread.Sleep(1000 * 2))现在它不传输的时候,我看了下cpu占用率50% 左右。分析原因:1. 使用了 while(true)这类的语句程序一直处原创 2018-01-29 10:02:06 · 10997 阅读 · 0 评论 -
log4net使用步骤
本文转自http://www.cnblogs.com/puzi0315/archive/2012/08/08/2628966.htmlLog4net监控服务状态对于比较复杂的逻辑,可以使用log4net来记录程序的执行过程中的关键数据,以此来监控服务的逻辑是否完备。1.在项目中引入log4net.dll组件(或者直接Nuget安装);2.在App.congfig中做如下修改(或者单独建立一个log...转载 2018-02-23 15:48:59 · 357 阅读 · 0 评论 -
C#开机自启动。
//---------------------------------------------------- #region 2.开机自启动。 public static void SetAutoRun(string fileName, bool isAutoRun) { RegistryKey registryKe...转载 2018-03-27 12:54:46 · 221 阅读 · 0 评论 -
C# 单例模式读取xml配置文件属性值
单例模式读取xml配置文件属性值要求: 程序启动后, 配置文件中的属性值要保持不变,才能起到作用;如果属性值在程序运行中一直在变化,那么就没有必要使用单例模式。class SingleXMLConfigInfo { #region 定义一个获取本地XML配置的单例模式类 //1.私有的构造函数 private SingleXML原创 2018-01-03 10:28:39 · 982 阅读 · 0 评论 -
c#压缩文件夹
压缩文件夹网上找了好久,终于找到了。(可以添加条件,挑选要的文件类型进行压缩。)using ICSharpCode.SharpZipLib.Checksums;using ICSharpCode.SharpZipLib.Zip;using System;using System.Collections.Generic;using System.IO;using System转载 2017-12-26 11:08:15 · 590 阅读 · 0 评论 -
c#控制台程序静默执行
class Program { #region 隐藏黑色窗口 [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)] static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);转载 2017-12-20 14:28:38 · 2164 阅读 · 0 评论 -
vs2012 安装 InstallShield
一、下载 InstallShield http://learn.flexerasoftware.com/content/IS-EVAL-InstallShield-Limited-Edition-Visual-Studio?lang=1033&ver=ult 随便注册一下,然后下载: 下载完成后,直接点击运行。 完成后,重启 vs2012, 就发现已原创 2017-12-12 16:51:34 · 1487 阅读 · 0 评论 -
c# 如何将下载完的dll文件加载到vs2012中
1. 找到引用的dll库文件所在本地目录。 查看库文件,所在目录:2. 然后找到手动找到该目录下,手动将dll添加原创 2017-10-24 16:34:13 · 824 阅读 · 0 评论 -
c# 应用程序的.dll文件更新。
using Microsoft.Win32;using System;using System.Collections;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Windows.F原创 2017-10-22 22:55:04 · 2147 阅读 · 0 评论 -
c#怎样根据文件名获取其所在的绝对路径
由于项目需要,用于更新pc端某些文件。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;using System.IO;namespace ConsoleApplication1{ cl原创 2017-10-17 23:33:01 · 3385 阅读 · 3 评论 -
c#中的"\r\n"区别?
根据ASCII码表表示 \r是回车 \n是换行例如:aaa\rbbb 则结果只显示为bbb,aaa会被覆盖;ccc\nddd则结果显示为ccc换行ddd;实验结果表明:\r只是将光标移到前面,后面数据会覆盖前面数据; 而\n表示换行。原创 2017-09-27 15:35:00 · 6937 阅读 · 0 评论 -
根据时间点 划分某一条记录归属
一、命名规范 1. 约定的字段名,驼峰命名 2. 数据库字段名,下划线命名二、c#中 根据时间点 划分某一条记录归属: 1. 首先用sql查询出所有记录,将每条的记录的时间和id 建立起字典。 2. 创建List集合,存字典的key值。 3. 比较key值-------> id ----> 一条记录。原创 2017-12-05 14:45:24 · 218 阅读 · 0 评论 -
C#判断字符串为空
字符串为空判断原创 2017-12-06 09:55:18 · 305 阅读 · 0 评论 -
c#程序 MQTT协议发送消息。
MQTT协议接收/发送消息 由于项目需要采用MQTT协议收/发送消息,首先购买了一个阿里云服务器,在其上安装 nginx服务器,安装Tomcat服务器,安装MQtt服务器。 说明:要下载一个 M2Mqtt.dll 文件,将这个dll文件引用到项目中。using System;using System.Collections.Generic;using System.Linq原创 2017-12-07 15:03:12 · 4401 阅读 · 0 评论 -
C#中的 String.format()方法用法解说
转载:https://blog.youkuaiyun.com/jiangyu1013/article/details/52607257JDK1.5开始String类中提供了一个非常有用的方法String.format(String format, Object ... args)查看源码得知其实是调用了java.util.Formatter.format(String, Object...)方法...转载 2018-07-16 20:29:31 · 13362 阅读 · 2 评论