代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Configuration;
namespace JiaowuHelper
{
class ConfigInfo
{
public string url = "";
public string username = "";
public string password = "";
public bool autoLogin = false;
}
class Config
{
public static ConfigInfo get()
{
ConfigInfo ci = new ConfigInfo();
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings.AllKeys.Contains("user"))
ci.username = config.AppSettings.Settings["user"].Value;
if (config.AppSettings.Settings.AllKeys.Contains("url"))
ci.url = config.AppSettings.Settings["url"].Value;
if (config.AppSettings.Settings.AllKeys.Contains("password"))
ci.password = config.AppSettings.Settings["password"].Value;
if (config.AppSettings.Settings.AllKeys.Contains("autoLogin"))
ci.autoLogin = Boolean.Parse(config.AppSettings.Settings["autoLogin"].Value);
return ci;
}
public static bool save(ConfigInfo ci)
{
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings.AllKeys.Contains("user"))
config.AppSettings.Settings["user"].Value = ci.username;
else
config.AppSettings.Settings.Add("user", ci.username);
if (config.AppSettings.Settings.AllKeys.Contains("url"))
config.AppSettings.Settings["url"].Value = ci.url;
else
config.AppSettings.Settings.Add("url", ci.url);
if (config.AppSettings.Settings.AllKeys.Contains("password"))
config.AppSettings.Settings["password"].Value = ci.password;
else
config.AppSettings.Settings.Add("password", ci.password);
if (config.AppSettings.Settings.AllKeys.Contains("autoLogin"))
config.AppSettings.Settings["autoLogin"].Value = ci.autoLogin.ToString();
else
config.AppSettings.Settings.Add("autoLogin", ci.autoLogin.ToString());
config.Save(ConfigurationSaveMode.Minimal);
return true;
}
catch
{
return false;
}
}
public static bool delete() {
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
File.Delete(config.FilePath);
return true;
}
catch {
return false;
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。