Delete a Temporary file

Bubbly
Posted by Bubbly under C# category on | Views : 1796
This subrouting deletes the temporary file that was created earlier. Check this link for creating a temp file : http://www.dotnetfunda.com/codes/code685-create-a-temporary-file.aspx

    
private void btnDeleteTempFile_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 = "Message";
return;
}
else
{
this.sbrStatus.Text = string.Empty;
}

// Attempt to delete the file.
try
{
File.Delete(m_FileName);
m_FileName = string.Empty;
this.txtTempFile.Text = string.Empty;
}
catch(Exception exc)
{
// Show error to user.
this.sbrStatus.Text = exc.Message;
}
}

Comments or Responses

Login to post response