winform ?????????????
???????????? ???????[ 2013/11/27 14:10:04 ] ????????
??????app.config??????????????£?
<configuration>
<appSettings>
<add key="ConStringEncrypt" value="false" />
<add key="ConnectionString" value="Server=localhost;Database=testmysql;User=root;Password=xiaowei;Port=3306;Charset=utf8" />
</appSettings>
</configuration>
?????????????д?????????????????????????????????????????
static class Program
{
/// <summary>
/// ??ó??????????
/// </summary>
[STAThread]
static void Main()
{
// ?????????????
string ConStringEncrypt = ConfigurationManager.AppSettings["ConStringEncrypt"];
string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
if (ConStringEncrypt == "false")
{
_connectionString = DESEncrypt.Encrypt(_connectionString);
// д??config?????
SetValue(Application.ExecutablePath + ".config"?? "ConStringEncrypt"?? "true");
SetValue(Application.ExecutablePath + ".config"?? "ConnectionString"?? _connectionString);
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}
public static void SetValue(string configPath?? string AppKey?? string AppValue)
{
XmlDocument xDoc = new XmlDocument();
//?????????????·????????
xDoc.Load(configPath);
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null) xElem1.SetAttribute("value"?? AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key"?? AppKey);
xElem2.SetAttribute("value"?? AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(configPath);
}
}
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11