public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); //Util.ResotreSettings(ref _serverList); _serverList1 = new Server[1]; _serverList1[0] = new Server(); _searchWord = new SearchWord(); _searchWord.BlackList.Add("異常:"); _searchWord.BlackList.Add("エラー"); _searchWord.WhiteList.Add("異常:マスタ更新"); Util.ResotreSettings(ref _serverList1, Server.PATH1); Util.ResotreSettings(ref _serverList2, Server.PATH2); Util.ResotreSettings(ref _searchWord); //Util.SaveSettings(_serverList1, Server.PATH1); //Util.SaveSettings(_serverList2, Server.PATH2); //Util.SaveSettings(_searchWord); // // TODO: Add constructor code after the InitializeComponent() call. // }
public static void SaveSettings(Server[] _settings, string path){ // //XMLファイルに保存する System.Xml.Serialization.XmlSerializer serializer1 = new System.Xml.Serialization.XmlSerializer(typeof(Server[])); System.IO.FileStream fs1 = new System.IO.FileStream(path, System.IO.FileMode.Create); serializer1.Serialize(fs1, _settings); fs1.Close(); }
public static void ResotreSettings(ref Server[] _settings, string path){ // //保存した内容を復元する System.Xml.Serialization.XmlSerializer serializer2 = new System.Xml.Serialization.XmlSerializer(typeof(Server[])); System.IO.FileStream fs2 = new System.IO.FileStream(path, System.IO.FileMode.Open); _settings = (Server[]) serializer2.Deserialize(fs2); fs2.Close(); }