Merge TXT

How to merge TXT files in C#

GroupDocs.Merger allows developers to merge TXT files when it’s needed to organize multiple TXT files into single document or send fewer attachments etc. And you can do this without¬†any third-party software or manual work involved. With GroupDocs.Merger it is possible to combine TXT documents of any size and structure - all text, images, tables, graphs, forms and other content will be preserved.

The following example demonstrates how to merge TXT files with several lines of C# code:

  • Create an instance of Merger class and pass source TXT file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
  • Add another TXT file to merge with Join method. Repeat this step for other TXT documents you want to merge.
  • Call Merger class Save method and specify the filename for the merged TXT file as parameter.
// Load the source TXT file
using (Merger merger = new Merger(@"c:\sample1.txt"))
    // Add another TXT file to merge
    // Merge TXT files ans save result

About TXT File Format

A file with .TXT extension represents a text document that contains plain text in the form of lines. Paragraphs in a text document are recognized by carriage returns and are used for better arrangement of file contents. A standard text document can be opened in any text editor or word processing application on different operating systems. All the text contained in such a file is in human-readable format and represented by sequence of characters.

Code Examples

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!

Merge TXT Live Demo

GroupDocs.Merger for .NET provides an online TXT Merger App, which allows you to try it for free and check its quality and accuracy.

“Merge TXT”