Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hello to all possible help I want to code to add a new line of the program


TextReader tr = new StreamReader("c:\\date.txt");
            
            
            // read a line of text
            String s1 = tr.ReadLine();
            // close the stream
            
            //String s1 = "One Two Three Four";
            char[] seps = {' '};
            String[] values = s1.Split(seps);
            TextWriter tw1 = new StreamWriter("d:\\bdate1.txt");
            

            // write a line of text to the file
            
            // close the stream
            for (int i = 0; i < values.Length; i++)
            {
                
                    tw1.WriteLine(values[i]);

                
            }          
            tr.Close();
            tw1.Close();
Posted
Updated 16-Oct-10 22:17pm
v2
Comments
Abhishek Sur 17-Oct-10 16:21pm    
From Avinav : I'm afraid your question is not very clear.
Can you explain what you require a little more precisely?

If you want to add a new line to the file, before closing it just do a tw1.WriteLine("Add my text here");

Using Environment.NewLine
C#
tw1.WriteLine(Environment.NewLine);

Using \r\n constant
C#
tw1.WriteLine("\r\n");
 
Share this answer
 
Comments
noor qudah 17-Oct-10 4:40am    
thanks alot
You may not use any arguments at all:
tw1.WriteLine();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900