Hi, why i can read and write to file?
Show error only on the "file". Any other well, but I can not read or write.
I use: using System.IO;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
file = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
StreamReader sr = new StreamReader(file);
string s = sr.ReadToEnd();
sr.Close();
file.Close();
}
private void button2_Click(object sender, EventArgs e)
{
SaveFileDialog of = new SaveFileDialog();
of.ShowDialog();
textBox2.Text = of.FileName;
MessageBox.Show(textBox2.Text);
FileStream file = new FileStream(textBox2.Text, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello file system world!");
sw.Close();
file.Close();
}