Use created temporary file

Bubbly
Posted by Bubbly under C# category on | Views : 1494
This subroutine uses the temp file that was created earlier.
Note : To create temp file visit this link : http://www.dotnetfunda.com/codes/code685-create-a-temporary-file.aspx

   
private void btnUseTempFilebtnUseTempFile_Click(object sender, System.EventArgs e)
{
// Clear the Status Bar or show error if there is no current file
if (m_FileName == string.Empty)
{
this.sbrStatus.Text = "Your Message";
return;
}
else
{
this.sbrStatus.Text = string.Empty;
}

// Attempt to use the temporary file, by adding some text to it and reading the text back out.
try
{
// Write to the temp file.
StreamWriter myWr = File.AppendText(m_FileName);
myWr.Flush();
myWr.Close();

// Read from the temp file.
StreamReader myRr = File.OpenText(m_FileName);

// Show contents of temp file to user.
this.sbrStatus.Text = myRr.ReadToEnd();
myRr.Close();

}
catch(Exception exc)
{
// Show error to user.
this.sbrStatus.Text = exc.Message;
}
}

Comments or Responses

Login to post response