private void CopyTo(SettingsDB target) { //直接引用,但此处不产生影响。 target.FileIndexInPath = this.FileIndexInPath == null ? new List <string>() : this.FileIndexInPath; target.FileIndexOutPath = this.FileIndexOutPath == null ? new List <string>() : this.FileIndexOutPath; target.MP3IndexInPath = this.MP3IndexInPath == null ? new List <string>() : this.MP3IndexInPath; target.MP3IndexOutPath = this.MP3IndexOutPath == null ? new List <string>() : this.MP3IndexOutPath; target.FileIndexPath = this.FileIndexPath == null ? new List <string>() : this.FileIndexPath; target.MP3IndexPath = this.MP3IndexPath == null ? new List <string>() : this.MP3IndexPath; }
/// <summary> /// 写设置 /// </summary> public void WriteSettings() { FileStream fs; BinaryFormatter bf = new BinaryFormatter(); SettingsDB settings = new SettingsDB(); this.CopyTo(settings); try { fs = new FileStream(Application.StartupPath + @"\Settings.db", FileMode.Create); try { bf.Serialize(fs, settings); } catch { } fs.Close(); } catch { } }
/// <summary> /// 读设置 /// </summary> public void ReadSettings() { FileStream fs; BinaryFormatter bf = new BinaryFormatter(); SettingsDB settings = new SettingsDB(); try { fs = new FileStream(Application.StartupPath + @"\Settings.db", FileMode.OpenOrCreate); try { settings = (SettingsDB)bf.Deserialize(fs); } catch { } fs.Close(); } catch { } settings.CopyTo(this); }
private void CopyTo(SettingsDB target) { //直接引用,但此处不产生影响。 target.FileIndexInPath = this.FileIndexInPath == null ? new List<string>() : this.FileIndexInPath; target.FileIndexOutPath = this.FileIndexOutPath == null ? new List<string>() : this.FileIndexOutPath; target.MP3IndexInPath = this.MP3IndexInPath == null ? new List<string>() : this.MP3IndexInPath; target.MP3IndexOutPath = this.MP3IndexOutPath == null ? new List<string>() : this.MP3IndexOutPath; target.FileIndexPath = this.FileIndexPath == null ? new List<string>() : this.FileIndexPath; target.MP3IndexPath = this.MP3IndexPath == null ? new List<string>() : this.MP3IndexPath; }