Skip to main content
added 148 characters in body; edited tags
Source Link
Dumbo
  • 14.2k
  • 56
  • 193
  • 294

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

 if (dr == DialogResult.OK)  {     StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);     sw.Write(sb.ToString());   sw.Close();  } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

The reason for this, is that somewhere in my text I have µ but when the file is saved it shows like μ so the µ is getting screwd!

Thanks

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

if (dr == DialogResult.OK) { StreamWriter sw = new StreamWriter(saveFileDialog1.FileName); sw.Write(sb.ToString()); sw.Close(); } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

Thanks

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

 if (dr == DialogResult.OK)  {     StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);     sw.Write(sb.ToString());   sw.Close();  } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

The reason for this, is that somewhere in my text I have µ but when the file is saved it shows like μ so the µ is getting screwd!

Thanks

deleted 71 characters in body
Source Link
CodeCaster
  • 152.6k
  • 24
  • 237
  • 287

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

 if (dr == DialogResult.OK)  {     StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);     sw.Write(sb.ToString());   sw.Close();  } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

Thanks

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

 if (dr == DialogResult.OK)  {     StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);     sw.Write(sb.ToString());   sw.Close();  } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

Thanks

I am trying to save a file using DialogResult and StringBuilder. After making the text, I am calling the following code to save the file:

if (dr == DialogResult.OK) { StreamWriter sw = new StreamWriter(saveFileDialog1.FileName); sw.Write(sb.ToString()); sw.Close(); } 

I tried to add the second parameter to StreamWriter as Encoding.UTF8 but since the first argument is a string rather than a Stream, it does not compile it.

How can I convert that string to a stream to be able to pass the second parameter as Encoding?

Thanks

edited tags
Link
Source Link
Dumbo
  • 14.2k
  • 56
  • 193
  • 294
Loading