The process cannot access the file because it is being used by another process.
Good Day
i am using a AsyncUpload(telerik), i am in a point where i am supposed to save the File to a certain Folder.
First i check if the directory exist
Code:
Dim baseDire As String = Server.MapPath("~/MyFILES/")
If IO.Directory.Exists(baseDire & Request("Req_ID").ToString()) = False Then
IO.Directory.CreateDirectory(baseDire & Request("Req_ID").ToString())
End If
Because i am doing multiple Upload , i will have to loop through the items of the Upload control and save to a folder.
Code:
For Each file As UploadedFile In UploadPropDoc.UploadedFiles
Dim bytes(file.ContentLength - 1) As Byte
file.InputStream.Read(bytes, 0, file.ContentLength)
'Save the File to the disk
file.SaveAs(baseDire + file.GetName())
Next
Now when ever i debug this , when it comes to this line
Code:
file.SaveAs(baseDire + file.GetName())
i get an Error
The process cannot access the file because it is being used by another process.
I have removed the Readonly in the Folder that it supposed to write to and gave everyone permission , but still the error persist.
Thanks
Re: The process cannot access the file because it is being used by another process.
Hello,
At the time of debugging, what is the full contents of baseDire? Also, what is the contents of file.GetName?
Also, have you given the worker process that is running ASP.Net Application, access to this folder?
Gary