I am trying to delete a file on the server, here is my code.

I first read the text from the file and put it into a text box

VB Code:
  1. Dim Sr As StreamReader
  2.         Dim sFile As String = "g:\" & Request.QueryString("MDN") & ".maildrop"
  3.         Sr = File.OpenText(sFile)
  4.        
  5.         Dim contents As String = Sr.ReadToEnd
  6.        
  7.         MailDropBox.Text = contents
  8.        
  9.         Sr.Close()
  10.         Sr = Nothing

then i edit the text and I click on the save button.
VB Code:
  1. Dim sFile As String = "g:\" & Request.QueryString("MDN") & ".maildrop"
  2.         File.Delete(sFile)
  3.         File.Create(sFile)
  4.         File.AppendAllText(sFile, MailDropBox.Text)

this process gives me this error on line [File.Delete(sFile)]:

The process cannot access the file 'g:\filename.maildrop' because it is being used by another process.

maybe there is a way to overwrite the text in the file, but i am not sure, I will read up more on the objects that I use.

Any help would be appreciated.

Thanks