permission denied runtime error 70

I'm writing a program that copies a file over another. Either of the files could be in use at any time by others (momentarily). I want to ensure that I won't get permission denied if one of the files is in use. My thought was a loop that waits for the file(s) to close(if needed), then copies it. How do I check if the file is in use

Thanks in advance for your help!



Answer this question

permission denied runtime error 70

  • sk4130

    I used a try catch as nbrege suggested. I had never heard of this before (I'm some what new to this). I set up a loop that attempts to check the file 100 times, each time if the try catch gives me an error saying the file is in use, I try again.

    While retry

    Try

    retry = False

    retries = retries + 1

    FileCopy(Location & "on.vbs", Location & Room.Name & "_01.vbs")

    Catch ex As System.IO.IOException

    If retries > 100 Then

    retry = False

    Else

    retry = True

    MsgBox("File in use error.")

    End If

    End Try

    End While

    Thanks again for your help.


  • 5982

    Would a Try...Catch work for you
  • esp123

  • Narayanan Dayalan

    Sorry for my ignorance, but what is a try...catch


  • Najeeb

    Thanks! I actually just got it working. (I should have looked in help before my last response, sorry.)


  • rmini

    Care to tell us how you achieved the correct result. (Others may find it useful)


  • permission denied runtime error 70