Results 1 to 4 of 4

Thread: Permission denied on Filecopy

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    86

    Permission denied on Filecopy

    I have the following code where I want to unzip a file in one directory to another. Then copy the zip into another folder and delete the zip then. I'm getting a permission denied error when I try to do the Filecopy. I think its because the zip file is still in use. How can I remove the read lock on the zip file from memory before trying to copy it?

    VB Code:
    1. Call Shell(Environ("ComSpec") & " /C C:\WINNT\PKUNZIP " + Trim(DestPathFile) + " E:\Archive\", vbHide)
    2.  
    3. FileCopy DestPathFile, FilePath
    4.        
    5. Kill DestPathFile

  2. #2
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575
    You could just wait for the Zip to complete before coping the file. I am sure I have used a shell-like function that waits until it is completed.

    You could also try to open the file in a loop - every time you get an error resume 0.
    My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]

  3. #3
    Member simlee's Avatar
    Join Date
    Mar 2002
    Posts
    40
    Instead of using the Shell Command, use ShellWait API - this will then wait until PKZip has finished before copying the file.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    86
    I tried using the ShellWait function but the zip file is still open. Even if i shut down the app and look in server manager, the zip is still open for read access. Is there a way of shutting down the file before I copy it?

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