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:
Dim Sr As StreamReader Dim sFile As String = "g:\" & Request.QueryString("MDN") & ".maildrop" Sr = File.OpenText(sFile) Dim contents As String = Sr.ReadToEnd MailDropBox.Text = contents Sr.Close() Sr = Nothing
then i edit the text and I click on the save button.
VB Code:
Dim sFile As String = "g:\" & Request.QueryString("MDN") & ".maildrop" File.Delete(sFile) File.Create(sFile) 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




Reply With Quote