Whenever I try to convert BinaryReader PeekChar or ReadChar to string it gives me an error
Error 1 'System.IO.BinaryReader.PeekChar()' is a 'method', which is not valid in the given context
How do I convert it? Here is my code sample:
private void openTextToolStripMenuItem_Click(object sender, EventArgs e)
{
myPath = textBox3.Text;
BinaryReader objBinReader = new BinaryReader(File.Open(myPath, FileMode.Open));
listBox1.Hide();
richTextBox1.Show();
richTextBox1.Text = "";
do
{
try
{
richTextBox1.Text = richTextBox1.Text + objBinReader.ReadChar.toString();
}
catch
{
MessageBox.Show(objBinReader.PeekChar.toString());
}
} while (objBinReader.PeekChar.toString() != "-1");
objBinReader.Close();
}
Thanks in advance!
toString()doesn't exist. The method is calledToString()Char. You'll have to cast it toCharbefore using it, otherwise you'll get a string with the numerica value