// フォルダに変更があった時の処理 private void Watcher_Changed(System.Object sender, System.IO.FileSystemEventArgs e) { switch (e.ChangeType) { // ファイル作成時の処理 case System.IO.WatcherChangeTypes.Created: if (!chkSuppressBalloon.Checked && SuppressWarning.isSuppressed(e.Name)) { this.notifyIcon1.BalloonTipText = BALLOONTIPTEXT_OTHER.Replace("%1", e.Name); this.notifyIcon1.ShowBalloonTip(5000); } break; } }
// 監視対象フォルダの項目名が変更された時 private void Watcher_Renamed(object sender, System.IO.RenamedEventArgs e) { if (!chkSuppressBalloon.Checked && SuppressWarning.isSuppressed(e.Name)) { // リネーム前後のファイル名表示:デバッグ用と言えばデバッグ用 notifyIcon1.BalloonTipText = "from: " + e.OldFullPath + "\nTo: " + e.FullPath; notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; notifyIcon1.ShowBalloonTip(5000); } // 全角空白エスケープを含むとき、かつ、抑制テキストを含まないとき if (e.Name.Contains(ESCAPED_MBSPACE) && SuppressWarning.isSuppressed(e.Name)) { // 当該ファイルをリネームする try { System.IO.File.Move(e.FullPath, e.FullPath.Replace(ESCAPED_MBSPACE, " ")); // 結果表示 this.notifyIcon1.BalloonTipText = BALLOONTIPTEXT_MBSPACE.Replace("%1", e.Name); this.notifyIcon1.ShowBalloonTip(5000); } catch (System.IO.IOException ioe) { MessageBox.Show(this, ioe.Message, APPTITLE, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show(this, ex.Message, APPTITLE, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (!chkSuppressBalloon.Checked) { this.notifyIcon1.BalloonTipText = BALLOONTIPTEXT_OTHER.Replace("%1", e.Name); this.notifyIcon1.ShowBalloonTip(5000); } } }