Generate standard-format txt

-1

Alright?

I need to generate a txt file with a default format as below:

D00000002       200014002154129   $9997 7720 0000 0012 *           12/19        *CLARICE LISPECTOR       *0014-00  215412-9       *     %B9997772000000012^CLARICE LISPECTOR

There will be several lines and all of them will have to be the same size and space between the data. What is the best way to generate these spaces (need to be even space, as a blank character) and ensure that the file is ok?

Thank you.

    
asked by anonymous 19.09.2018 / 21:21

1 answer

0

You can use the methods String.PadLeft or String.PadRight

string str = "Lorem ipsum";
Console.WriteLine(str.PadLeft(15));  // "    Lorem ipsum"
Console.WriteLine(str.PadRight(5));  // "Lorem ipsum   "
    
19.09.2018 / 21:43