Escaping a formatter {} in StreamWriter

  • Thread starter Thread starter BR
  • Start date Start date
B

BR

Hi,

I found one issue with the StreamWriter class where the
StreamWriter.Write API interprets anything between { } as a formatter.
So if I write myStreamWriter.Write("This is test code { Ha Ha Ha }
string contd"); then I get a FormatException. I have not been able to
find a clean way of escaping the { ... } so that StreamWriter does not
treat it as a formatter.

Does some one know how to do this?

Thanks,
Roshan
 
BR said:
Hi,

I found one issue with the StreamWriter class where the
StreamWriter.Write API interprets anything between { } as a formatter.
So if I write myStreamWriter.Write("This is test code { Ha Ha Ha }
string contd"); then I get a FormatException. I have not been able to
find a clean way of escaping the { ... } so that StreamWriter does not
treat it as a formatter.

Does some one know how to do this?

Thanks,
Roshan

The string is only used as a format if you have more arguments in the
Write call. If you want to write a string, you should have only that
string as argument.
 
Back
Top