C#. Join (merge) some text files into one




The task. We have 3 separated text files, for example, web server logs. For more comfortable analyze we want to join them into one file. Below my simple solution for this task in C#.

The main steps of script are:

  1. Read directory and get filenames. Add names to array of string
  2. Loop through array of filenames, read contents of files and add it to string collection List<string> stringList
  3. Join string collection List<string> to a string variable
  4. Write result to textFile

 

Full code of console application below. It's the simple version. You may add more features to a code if you want to.

joinedFiles




No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





MarkiMarta.com. Notes of web-specialist
Since 2009
18+