private void MergeLTDFiles(DocumentFormat format, string outputFileName, string[] sourceLTDFiles, bool viewFinalDocument, LtdDocumentType globalLTDType) { // If the output format is LTD then use the same target LTD file path specified by the user, otherwise create a temp file string mergedLTDFileName = null; if (format != DocumentFormat.Ltd) { mergedLTDFileName = Guid.NewGuid().ToString().Replace("-", null) + "." + "ltd"; mergedLTDFileName = Path.Combine(Path.GetTempPath(), mergedLTDFileName); } else { mergedLTDFileName = outputFileName; if (File.Exists(outputFileName)) { File.Delete(outputFileName); } } bool errorOccurred = false; try { if (sourceLTDFiles.Length > 0) { foreach (string fileName in sourceLTDFiles) { if (_abort) { break; } _docWriter.AppendLtd(fileName, mergedLTDFileName); } if (format != DocumentFormat.Ltd) { _docWriter.Convert(mergedLTDFileName, outputFileName, format); } } else { errorOccurred = true; OnError("Non of the source LTD files you added matches the chosen global LTD document type from the previous page."); } } catch (Exception ex) { errorOccurred = true; OnError(ex.Message); } finally { OnDone(format, mergedLTDFileName, outputFileName, viewFinalDocument, errorOccurred); } }