Merge Text File

  • Thread starter Thread starter MFRASER
  • Start date Start date
string str = string.Empty();
StreamReader sr = File.OpenText("file01.ext");
StreamWriter sw = File.AppendText("file02.ext");

while( ( str = sr.ReadLine() ) != null )
sw.WriteLine(str);
 
If they are both of the same encoding, treat them as binary files, Read a
constant block size in a loop and write into the second file.

If they're both of different encoding type, you'd need to read them in as
string (using ReadLine APIs) and write them using the appropriate encoding.

-vJ
 
Back
Top