title: Format table in C# console application with strings of varying length
body: <p>I looked through the website, couldn't find anything that specifically addressed the issue.</p>
  
  <p>I have a console app that loops through, finds strings between 7-20 characters, plus date/time, plus a Flag, plus the file.</p>
  
  <pre><code>    Console.Write("=========================================================================");
  Console.WriteLine("Start time: " + DateTime.UtcNow);
  Console.Write("=========================================================================");
  Console.WriteLine("All times in UTC.");
  Console.Write("=========================================================================");
  Console.WriteLine(String.Format("{0,-8}{1,17}{2,37}{3,13}", "Time", "File:Offset", "F", "String"));
  Console.Write("=========================================================================");
  </code></pre>
  
  <p>The problem is the string and filename+path can be varying length.  The Output uses the same string format, but depending on the length of the filename, the formatting is off.</p>
  
  <p>Is there a way to have the console write items starting at a fixed position everytime.<br>
  So Time starts at 0, file:offsett starts at 17, F starts at 37, and String starts at 40.  That way it formats properly.  Also, this may be a bit more advanced, but can it truncate anything that won't fit in the column?</p>
  
  <p>Thanks!</p>