The process cannot access the file because it is being used by another process.

Posted by Vuyiswamb under ASP.NET AJAX on 2/6/2012 | Points: 10 | Views : 1893 | Status : [Member] [MVP] [Administrator] | Replies : 0
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


 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.

 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

 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

Thank you for posting at Dotnetfunda
[Administrator]



Responses

(No response found.)

Login to post response