What is the best way to create a fixed width file in C#. I have a bunch of fields with lengths to write out. Say 20,80.10,2 etc all left aligned. Is there an easy way to do
Use the .PadRight function (for left aligned data) of the String class. So:
handle.WriteLine(s20.PadRight(20)); handle.WriteLine(s80.PadRight(80)); handle.WriteLine(s10.PadRight(10)); handle.WriteLine(s2.PadRight(2));