I’m implementing a Windows application to make planning projects easier at my workplace and I was wondering if there’s any clever way of making a txt-file nicely structured.
The application is really very simple, pretty much what it does is give the user a question which is answered in a textbox bellow. The question AND the answer are then both sent to a file but it looks very tacky.
Example:
Question?Answer!Question?Answer!
I would like it to be more like this:
Question?
Answer!
Question?
Answer!
I was also curious about other types files, is it possible to use Pdf or MS word the same way as txt?
You can use
File.AppendAllLines()and pass in the different strings as an array. They will appear as separate lines in the text file. You’ll also need to add ausing System.IOat the top of your file.For example:
I hope this is what you’re after – the question is a little vague.
As for Word and PDF files, this is more complex. Here’s a link to a StackOverflow question about Word:
How can a Word document be created in C#?
and one about PDF:
Creating pdf files at runtime in c#