Results 1 to 2 of 2

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

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width