Posts

Showing posts from March 7, 2012

READING MULTIPLE TEXT FILES AND SAVING THE CONTENT TO A SINGLE FILE

Image
First step is selecting the file paths and then read the file using Stream Reader and save the content to the string builder.  After doing this for all the files, now our content is in the string builder. Now create a file with the file stream (using file stream is easily can easily kill the process).  Now write the content of the string builder to the newly created file using the Stream Writer. I have done this in winforms.  You can download the demo here. Our UI looks like this.             UI consists of two buttons, one( btnBrowse) for browsing or selecting the text files and another( btnSaveResult) for saving the new file with the combined content.  One textbox for viewing the combined content.  Apart from these controls we have added one OpenFileDialog control and one SaveFileDialog control for selecting the files and saving the newly created file respectively. Now lets jump into the code. Using System; using System.Collections.Generic; using Sys