How to copy files line by line in C#

1 Answer

0 votes
using System;
using System.IO;

namespace Copy_TextFile_Line_By_Line
{
    class Program
    {
        static void Main(string[] args)
        {
			string path_read = "d:\\test.txt";
			string path_write = "d:\\test_copy.txt";
            string s;

			StreamReader sr = File.OpenText(path_read);
			StreamWriter sw = File.CreateText(path_write);
				
			while ((s = sr.ReadLine()) != null) 
				sw.WriteLine(s);

			sr.Close();
			sw.Close();
        }
    }
}



answered Sep 4, 2014 by avibootz

Related questions

...