Results 1 to 2 of 2

Thread: CopyFile API problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Location
    North Carolina
    Posts
    131

    CopyFile API problem

    I just ran into a problem using the copyfile api. I was trying to copy a file from one server to another using the copyfile api and it kept failing to copy the file. I couldn't figure out why it was failing. After about thirty minutes of going through my code I tried to manually copy the file and got an error stating there wasn't enough disc space. Is there a way of trapping for this or any other error that may occur while using this api?

    I know that I can verify the file was copied by doing something like this:

    VB Code:
    1. dim RET as Long
    2.  
    3. RET = copyfile(sourcefile, destfile,0)
    4.  
    5. IF RET > 0 then
    6.     msgbox "file copied"
    7. else
    8.     msgbox "file not copied"
    9. END IF

    But, if it fails I have no way of knowing why.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    After your call to CopyFile, use the FormatMessage API to get the reason for the failure. Just pass in Err.LastDllError for the error number...

    http://www.vbforums.com/showthread.p...=formatmessage
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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