Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I built a form using C#.NET. It has lot of text boxes. I am trying to save and print the information in the text boxes. I used the code below:

I am able to save it as a text file in four different lines and print it. I would like to have all of them in the same line. How can I write the code? Thanks for your help.

What I have tried:

C#
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
 if ((myStream = saveFileDialog1.OpenFile()) != null)
    {
     using (var writer = new StreamWriter(myStream))
           {
            writer.WriteLine("Information of Quote Number: ");
            writer.WriteLine(textbox1.Text);        
            writer.WriteLine("Total Cost: ");
            writer.WriteLine(textbox2.Text);
            }
     }    
            myStream.Close();
}
Posted
Updated 5-Dec-16 5:44am
v2

1 solution

Use
C#
writer.Write()
where a newline is not required.
Refer: StreamWriter[^]
 
Share this answer
 
v4
Comments
Savi kolla 5-Dec-16 11:46am    
Thanks so much!
Peter Leow 5-Dec-16 11:46am    
You are welcome.

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