This subroutine finds the path to the Temp directory on the local machine. It is ALWAYS important to wrap any Path
method calls in a try-catch block since exceptions are thrown based on the permissions granted to the current user.
private void btnFindTempDirectory_Click(object sender, System.EventArgs e)
// initialize to an empty string.
string tempPthstr = string.Empty;
// Clear the Status Bar.
this.sbrStatus.Text = string.Empty;
// Attempt to get the path to the Temp directory
tempPthstr = Path.GetTempPath();
// Show error to user, if they don't have the proper permissions
this.sbrStatus.Text = "Required Message here";
// Show error to user.
this.sbrStatus.Text = "Required Message her";
// Set txtTempDirectory equal to the Temp path.
this.txtTempDirectory.Text = tempPthstr;