8
Answers

Writing Bytes to a text file

kiran murthy

kiran murthy

12y
1.2k
1
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)