Wednesday, July 30, 2014

Program to Copy the file contents from one file to copy part of line in another file throughout



using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apps
{
    class FileContentSeperation
    {
        static void Main(string[] args)
        {
            //FileStream fs = new FileStream() 
            StreamReader sfilecontent1 = new StreamReader(@"D:\Practice Applications\Srikanth Tech\File1.txt");
            StreamWriter dfilecontent2 = new StreamWriter(@"D:\Practice Applications\Srikanth Tech\File2.txt");
            string line;
            //Console.WriteLine(line);
            while ((line = sfilecontent1.ReadLine()) != null)
            {
                string[] words = line.Split(',');
                string k = words[1];
                dfilecontent2.Write(k.Trim() + "\r\n");
            }
            sfilecontent1.Close();
            dfilecontent2.Close();
        }
    }
}

No comments:

Post a Comment