Error when trying to replace .txt file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
when i want to replace a file that i opened but i get an error on the under lined code when i try


<pre class="prettyprint private void button2_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "*.txt (text file)|*.txt";

if (ofd.ShowDialog() == DialogResult.OK)
{
ObjStream = new StreamReader(ofd.FileName);
input1.Text = ObjStream.ReadToEnd();
}
}
catch (Exception ect)
{
MessageBox.Show("an error has occured: " + ect.Message);
}

}

private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "*.txt (text file)|*.txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
<span style="text-decoration:underline input1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);
}
}[/code]
<br/>


View the full article
 
Back
Top