Help with loading files into rich text box
OK, I followed the Microsoft MSDN and copied their code exactly, and it work for RTF files only, but I want to be able to open text files, html files, php files....basically any files.
The code is:
public partial class Form1 : Form
private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
public void LoadMyFile()
// Create an OpenFileDialog to request a file to open.
OpenFileDialog openFile1 = new OpenFileDialog();
// Initialize the OpenFileDialog to look for RTF files.
openFile1.Filter = "Text Files|*.txt";
// Determine whether the user selected a file from the OpenFileDialog.
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
openFile1.FileName.Length > 0)
// Load the contents of the file into the RichTextBox.
private void openmenu1_Click(object sender, EventArgs e)
I get this error when I double click on the file to open:
"File Format is not valid", and it relates to this code:
I am a beginner in C#, and want to understand how it works,