/// <summary> /// Setting のコンストラクタ /// </summary> private Setting() { this.filepath = System.IO.Path.Combine(Path.ExecutableDirectory, SETTING_FILENAME); //--保存先のファイルが存在しないとき if (!System.IO.File.Exists(this.filepath)) { this.makeXml(); } //--読み込み try{ this.Load(this.filepath); } catch { ConfirmOverwriteSetting.Result r = ConfirmOverwriteSetting.Confirm(); if (r.overwrite) { if (r.backup) { System.IO.File.Move(this.filepath, Path.GetAvailablePath(this.filepath, "bk")); } this.makeXml(); } else { this.filepath = ""; } this.LoadXml(DEFAULT_SETTING); } }
private void InitCacheFile() { // cachedir string cachedir = AfhPath.Combine(AfhPath.ExecutableDirectory, "cache"); AfhPath.EnsureDirectoryExistence(ref cachedir); // temppath temppath = AfhPath.Combine(cachedir, rand.Next(0x1000000).ToString("X6")); temppath = AfhPath.GetAvailablePath(temppath, "tmp"); this.tempostr = System.IO.File.Open( temppath, System.IO.FileMode.CreateNew, System.IO.FileAccess.ReadWrite ); }
/// <summary> /// 現在の設定を保存します。 /// </summary> public void Save() { if (this.filepath == "") { ConfirmOverwriteSetting.Result r = Configuration.ConfirmOverwriteSetting.Confirm2(); if (!r.overwrite) { return; } this.filepath = System.IO.Path.Combine(Path.ExecutableDirectory, SETTING_FILENAME); if (r.backup) { System.IO.File.Move(this.filepath, Path.GetAvailablePath(this.filepath, "bk")); } } base.Save(this.filepath); }