编码
添加using
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Text;
PropertiesConfig
class PropertiesConfig {
private static Hashtable _ht = new Hashtable(16);
static PropertiesConfig() {
var ht = new Hashtable();
string file = @"app.properties";
if (!File.Exists(file)) {
//将变量列入到配置文件中
_ht=initProperties();
save(file,_ht);
} else {
//加载配置文件,验证配置文件,保存配置文件
_ht = load(file);
if (validate()) {
save(file, _ht);
}
}
}
private static Hashtable initProperties() {
_ht["project.name"] = "合光机器人知识库";
_ht["manager.url"] = "http://ibotcluster.online.uairobot.com/manager";
return _