/// <summary> /// 同時起動ショートカット作成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateLauncher_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "同時起動のショートカットを指定してください。"; fileDialog.Filter = "URL Files (.url)|*.url|LNK Files (*.lnk)|*.lnk|EXE Files(*.exe)|*.exe"; if (fileDialog.ShowDialog() == true) { string createPath = SysIO.Path.Combine(SysIO.Path.GetDirectoryName(fileDialog.FileName), SysIO.Path.GetFileNameWithoutExtension(fileDialog.FileName) + "_QRCodeWebLoader.bat"); using (StreamWriter writer = new StreamWriter(createPath, false)) { writer.WriteLine("start " + System.Reflection.Assembly.GetExecutingAssembly().Location + " 1 \"" + fileDialog.FileName + "\""); writer.Close(); } DefaultDialog error = new DefaultDialog("完了"); error.SetMsg("ショートカットを作成しました。\n[" + createPath + "]"); error.ShowDialog(); return; } }
/// <summary> /// 監視開始 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Watcher_Click(object sender, RoutedEventArgs e) { QRDataSave(); if (fileWatcher.EnableRaisingEvents) { fileWatcher.EnableRaisingEvents = false; Watcher.Content = "読取開始"; Status.Content = "読み取り停止中"; FileDirPath.IsEnabled = true; DirDialog.IsEnabled = true; ReLoad.IsEnabled = true; Delete.IsEnabled = true; } else { fileWatcher.EnableRaisingEvents = false; if (!Directory.Exists(FileDirPath.Text)) { DefaultDialog error = new DefaultDialog("エラー"); error.SetMsg("フォルダが存在しません。"); error.ShowDialog(); return; } fileWatcher.Path = FileDirPath.Text; fileWatcher.NotifyFilter = (NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.Security); fileWatcher.Filter = ""; fileWatcher.IncludeSubdirectories = false; fileWatcher.Changed += new FileSystemEventHandler(Watcher_Changed); fileWatcher.Created += new FileSystemEventHandler(Watcher_Changed); fileWatcher.Renamed += new RenamedEventHandler(Watcher_Renamed); fileWatcher.EnableRaisingEvents = true; Watcher.Content = "読取停止"; Status.Content = "読み取り中"; FileDirPath.IsEnabled = false; DirDialog.IsEnabled = false; ReLoad.IsEnabled = false; Delete.IsEnabled = false; } }