// 出力ファイル名を取得 public string GetOutputPath(int jk, string defaultName = "") { string outputPath = string.IsNullOrEmpty(OutputFileName) ? "" : OutputFileName.EndsWith(@"\") ? OutputFileName : Path.GetDirectoryName(OutputFileName); string outputName = Path.GetFileName(OutputFileName); if (Directory.Exists(OutputFileName)) { outputPath = OutputFileName; outputName = ""; } if (string.IsNullOrEmpty(outputName)) { outputName = defaultName; } if (string.IsNullOrEmpty(outputPath)) { outputPath = ""; } else if (!outputPath.EndsWith(@"\")) { outputPath += @"\"; } if (CreateDirectory) { outputPath += $"jk{jk}" + @"\"; } return(outputPath + outputName); }