From 04535f2dd86c8dc67a093bb119dad35a5fe34767 Mon Sep 17 00:00:00 2001 From: tsuji Date: Fri, 8 Oct 2021 17:52:40 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E6=99=82=E3=81=AE=E3=83=95=E3=83=AA=E3=83=BC=E3=82=BA?= =?UTF-8?q?=E7=AD=89=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GetADoc/MainWindow.xaml.cs | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/GetADoc/MainWindow.xaml.cs b/GetADoc/MainWindow.xaml.cs index 2c2eef7..f2c0b9a 100644 --- a/GetADoc/MainWindow.xaml.cs +++ b/GetADoc/MainWindow.xaml.cs @@ -116,11 +116,48 @@ namespace GetADoc { fileName = fileName.Replace(allNg, string.Empty); } - MessageBox.Show("ファイル名に使用できない文字が存在したため\n一部ファイル名を修正しました。\nもう一度作成ボタンをクリックしてください。", "Renamed this file", MessageBoxButton.OK, MessageBoxImage.Warning); + MessageBox.Show("ファイル名に使用できない文字が存在したため\n一部ファイル名を修正しました。" + + "\nもう一度作成ボタンをクリックしてください。", "Renamed this file", MessageBoxButton.OK, MessageBoxImage.Warning); box2.Text = fileName; return; } + //指定したフォルダに同名の.adocや既存の付属ファイル(config.adocなど)がある場合の処理 + if (File.Exists(System.IO.Path.Combine(filePath, fileName + ".adoc")) || File.Exists(System.IO.Path.Combine(filePath, "config.adoc"))) + { + MessageBoxResult OverwriteADoc = MessageBox.Show("これから生成するファイルと同名のファイルが既に存在します" + + "\n既存のファイルを上書きしますか?", + "指定したフォルダに既存のファイルが存在します", + MessageBoxButton.YesNo); + if (OverwriteADoc == MessageBoxResult.Yes) + { + File.Delete(filePath + fileName + ".adoc"); + File.Delete(System.IO.Path.Combine(filePath, "config.adoc")); + File.Delete(System.IO.Path.Combine(filePath, "IncDoc.adoc")); + if (Directory.Exists(System.IO.Path.Combine(filePath, "Images"))) + { + Directory.Delete(System.IO.Path.Combine(filePath, "Images"), true); + } + if (Directory.Exists(System.IO.Path.Combine(filePath, "icons"))) + { + Directory.Delete(System.IO.Path.Combine(filePath, "icons"), true); + } + if (Directory.Exists(System.IO.Path.Combine(filePath, "Sub_First"))) + { + Directory.Delete(System.IO.Path.Combine(filePath, "Sub_First"), true); + } + if (Directory.Exists(System.IO.Path.Combine(filePath, "Sub_Second"))) + { + Directory.Delete(System.IO.Path.Combine(filePath, "Sub_Second"), true); + } + } + else if(OverwriteADoc == MessageBoxResult.No) + { + MessageBox.Show("別のフォルダを指定してください"); + return; + } + } + //バッチファイルの実行 ProcessStartInfo processStartInfo = new ProcessStartInfo(); string stCurrentDir = System.IO.Directory.GetCurrentDirectory(); @@ -151,7 +188,7 @@ namespace GetADoc //指定されたフォルダに生成物を移動 File.Move(System.IO.Path.Combine(stCurrentDir, fileName + ".adoc"), filePath + fileName + ".adoc"); - File.Move(System.IO.Path.Combine(stCurrentDir, "config.adoc"), filePath + "/config.adoc"); + File.Move(System.IO.Path.Combine(stCurrentDir, "config.adoc"), System.IO.Path.Combine(filePath, "config.adoc")); Directory.Move(System.IO.Path.Combine(stCurrentDir, "Images"), System.IO.Path.Combine(filePath, "Images")); if (checkbox2.IsChecked == true) { -- 2.22.0