We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,231 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Format information that gets written to text file...

I wrote code that will send all my textbox information to a text file. It successfully goes there but it is all in one line and in no type of order.

What I wanted to do was have it in on line spaced correctly and possibly with column headers to help the user better understand what was output. Also since multiple users will be using this code I wanted to space each output line by a blank line.

If someone could help me or point me in the right direction that would be great!

Thank you!

here is the code I have for the output file:

protected void Browse_Click(object sender, EventArgs e)
        {
            string FileName = "ExporterOutput.txt";
            string FilePath = "C:/Users/456546757/My Documents/ExporterOutput.txt";
            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            response.ContentType = "text/plain";
            response.AddHeader("Content-Disposition", "attachment; filename = " + FileName + ";");
            response.TransmitFile(FilePath);
            response.Write(username.Text);
            response.Write(authlvl.Text);
            response.Write(DropDownList1.Text);
            response.Write(DropDownList2.Text);
            response.Write(sgml.Text);
            response.Flush();
            response.End();
        }
2
Contributors
3
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
4
Views
compulove
Junior Poster in Training
68 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I think you can add a "<BR>" literal after each value like
response.Write(username.Text & "<BR>");

Hope this helps

lolafuertes
Practically a Posting Shark
890 posts since Oct 2008
Reputation Points: 164
Solved Threads: 189
Skill Endorsements: 5

I think you can add a "<BR>" literal after each value like
response.Write(username.Text & "<BR>");

Hope this helps

I keep getting the error that the "&" operator cannot be appled to operands of type string?

compulove
Junior Poster in Training
68 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Sorry, the string concatenation operator is the plus sign (+).

lolafuertes
Practically a Posting Shark
890 posts since Oct 2008
Reputation Points: 164
Solved Threads: 189
Skill Endorsements: 5

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0671 seconds using 2.69MB