Search code examples
c#tabsword-wrap

c# tab wrapped string


I am writing out a large string (around 100 lines) to a text file, and would like the entire block of text tabbed.

WriteToOutput("\t" + strErrorOutput);

The line I am using above only tabs the first line of the text. How can I indent/tab the entire string?


Solution

  • Replace all linebreaks by linebreak followed by a tab:

    WriteToOutput("\t" + strErrorOutput.Replace("\n", "\n\t"));