Escaping a formatter {} in StreamWriter

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top