public static bool CSVExport <TResult>(string fileLocation, IEnumerable <TResult> searchResult) where TResult : ISearchResult { var overlapOption = SettingManager.ExportOptionSetting.CSVOverlapOption; if (File.Exists(fileLocation)) { if (overlapOption == FileOverrideOption.ThrowError) { TaskLogManager.AddLog($"'{fileLocation}' 위치가 비어있지 않습니다. CSV로 내보낼 수 없었습니다.", TaskLogType.Failed); return(false); } else if (overlapOption == FileOverrideOption.AppendAdditionalNumber) { int number = 1; var info = new FileInfo(fileLocation); while (true) { string tempName = $"{Path.Combine(info.DirectoryName, info.Name)} ({number++}).csv"; if (!File.Exists(tempName)) { fileLocation = tempName; break; } continue; } } } var csvFormat = new CSVFormat <TResult>(); string str = csvFormat.FormattingData(searchResult); return(str.SaveAsFile(fileLocation, (File.Exists(fileLocation) && overlapOption == FileOverrideOption.AppendContent))); }