This article will show you how to merge the text of text files located in a directory.
string[] txtFiles;
txtFiles = Directory.GetFiles(txtFileDestination.Text, "*.txt");
using (StreamWriter writer = new StreamWriter(txtFileDestination.Text + @"\allfiles.txt"))
{
for (int i = 0; i < txtFiles.Length; i++)
{
using (StreamReader reader = File.OpenText(txtFiles[i]))
{
writer.Write(reader.ReadToEnd());
}
}
}
[Modified: it really doesn't take much to fix the tabbing...]
I am working as a Team Leader in HimanshuSofttech(http://www.himanshusofttech.com) a new born Search Engine Optimization and software developement Company Located in Dewas, A Holy place of India. I started my programing life as a VB.NET Developer but now I am working in C#.NET.