Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string[] ttt = new ClearableListDataHelper().GetDomains();
                if (ttt != null)
                {
                    try
                    {
                        string tempFile         = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "兼容性视图配置.ieviewconfig");
                        ClearableListObject clo = new ClearableListObject();
                        clo.WebSiteList.AddRange(ttt);
                        ClearableListObject.toFile(clo, tempFile);

                        MessageBox.Show("保存完成!路径:" + tempFile);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("保存失败!Ex:" + ex.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败!Ex:" + ex.ToString());
            }
        }
Beispiel #2
0
        public MainForm()
        {
            InitializeComponent();

            //载入配置
            try
            {
                if (System.IO.File.Exists(configFile))
                {
                    Config = ClearableListObject.fromFile(configFile);
                }
                else
                {
                    Config = new ClearableListObject();
                    Config.WebSiteList.Add("test.com");
                    ClearableListObject.toFile(Config, configFile);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("配置文件载入失败!Ex:" + ex.ToString());
            }
        }
Beispiel #3
0
 /// <summary>
 /// 序列化
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="jsonFile"></param>
 public static void toFile(ClearableListObject obj, string jsonFile)
 {
     System.IO.File.WriteAllText(jsonFile, JsonConvert.SerializeObject(obj, Formatting.Indented));
 }