Answer the question
In order to leave comments, you need to log in
How to read file as string in BinaryReader?
Stupid question, but I hope it helps.
In general, I'm trying to find a line in a binary file, add a byte and read the data after it and output it to the label. Problem with filling variable content
, I tried like this
string content = File.ReadAllText(@"D:\Player.chr");
but when executed, it throws an exception that the file is busy, which is logical. Well, in general, probably the wrong approach. Tell me how to be right?using (var file = File.Open(@"D:\Player.chr", FileMode.Open, FileAccess.ReadWrite))
{
using (var br = new BinaryReader(file, Encoding.Unicode))
{
string content = ""; // тут надо считать в строку
var offset = content.IndexOf("money");
offset += "money".Length + 1;
br.BaseStream.Position = offset;
label1.Text = offset.ToString();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question