C#编写windows服务程序
1.添加引用
using System.Configuration;
C# ConfigurationManager不存在问题解决
https://www.cnblogs.com/dobiprogrammer/p/9132257.html
在做串口通信的时候,需要使用"ConfigurationManager"类,但是添加"Using System.Configuration"命名空间后编译器依旧报错,总是显示"ConfigurationManager"不存在,但是发现"ConfigurationSettings"可以使用,但是在MSDN上的备注中显示的是"使用 ConfigurationManager 类,可以访问计算机、应用程序和用户的配置信息。 此类替换已被否决的"ConfigurationSettings"类。"开始是怀疑使用的.NET版本太老,但是查看后发现并不是,仔细的看了MSDN的技术文档后发现"ConfigurationManager"类是不能被继承的,同时又说System.Configuration程序集在System.Configuration.dll中,所以在解决方案的引用中添加了System.Configuration的引用,问题完美解决。
2.添加类
【1】AppManager.cs
【2】ImportDataLog.cs
【3】GenerateTXTManager.cs
【4】SqlHelper.cs
3.配置文件
txtTime
<!--生成txt文件时间点-->
<add key="txtTime" value="19:30" />
txtDay
<add key="txtDay" value="2016-09-20" />
txtStartStatus
<!--是否已经开始生成txt文件-->
<add key="txtStartStatus" value="false" />
LogPath
<add key="LogPath" value="E:\txt_保定\LOG\" />
con
<add key="con" value="Data Source=59.108.92.220,1434;Initial Catalog=ChinaAirQuality;Persist Security Info=True;User ID=sa;Password=yutu_r2" />
txtFilePath
<add key="txtFilePath" value="E:\txt_保定\TXT\" />