kiran murthy

kiran murthy

  • NA
  • 13
  • 7.5k

Writing Bytes to a text file

Aug 2 2012 6:56 AM
Guys i am trying to use the following lines of code, but when i check out the file that is being saved, all i see is the exact same text. but not the converted bytes, What am i doing wrong?



String text = "Line 1" + Environment.NewLine;
text += "Line 2" + Environment.NewLine;
text += "Line 3" + Environment.NewLine;
text += "Line 4" + Environment.NewLine;
Byte[] b = Encoding.ASCII.GetBytes(text);
File.WriteAllBytes(path, b);

Answers (8)