Click here to Skip to main content
15,892,746 members

Sentences to line with StreamReader txt to txt ?

Revision 2
read c.txt
write only different values to 21.txt
its ok
but I cant read sentece it only read line :(
c.txt have senteces so I want to read word word to write 21.txt line line :).

C#
static void Main(string[] args)
        {
            string d = @"C:\C.txt";
            FileStream f = new FileStream(d,FileMode.Open);            
            StreamReader s = new StreamReader(f);

            string d2 = @"C:\21.txt";
            FileStream f2 = new FileStream(d2,FileMode.Create, FileAccess.Write);
            StreamWriter s2 = new StreamWriter(f2);


            ArrayList lst = new ArrayList();
            
            
            string line;
            while ((line = s.ReadLine()) != null)
            {                
                if(!lst.Contains(line)){
                lst.Add(line);
                }              
            }
            
            foreach(Object lstt in lst){
              
                //Console.WriteLine(lstt);
                s2.WriteLine(lstt);
            }


            s2.Flush();
            s2.Close();
            s.Close();
            Console.ReadLine();

        }
Posted 8-Nov-12 15:44pm by Member 9522119.
Tags: ,