file cannot be deleted used by another process
<p>hi
 when ever i try to delete this files  some times i get this message
<strong>file cannot be  deleted  used by another process</strong> 
even though file is not used by any other  user 
the code  what i am using </p>

<pre><code>try 
{

FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists) {
File.Delete(MapPath(".") + "\\" + txtFile.Text);
} 
else {

throw new FileNotFoundException();
}
}

catch (FileNotFoundException ex) {

lblStatus.Text += ex.Message;
}
</code></pre>

<p>is there way we can assign a  boolean value<br>
<strong>here if  true means i can display an message tellingfile is deleted successfully</strong>
  boolean value   is false 
<strong>here if  false means i can display an message telling file used by another process</strong></p>

<p>can i   write that  condition here 
<code>File.Delete(MapPath(".") + "\\" + txtFile.Text);</code>
   any help would be great thank you </p>
