Deleting a file

S

Sobhan Vezzu

Hi All,


Using a webpage I am uploading the file onto webserver. First time
it works fine. If I use the same file from second time it throws an
error.

Error:
"The process cannot access the file "<FileName>" because it is being
used by another process."

My code is as follows:
If Not (File1.PostedFile Is Nothing) Then
' Create new directory if not present
If Not (Directory.Exists(strDirPath)) Then
Directory.CreateDirectory(strDirPath)
End If

' Save the uploaded file in the directory
File1.PostedFile.SaveAs(strDirPath + "\" + strFileName)
End If
Any suggestions would be appreciated.
Regards
Sobhan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top