Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Wait for 'CopyFile' to finish copying the file?

Posted on 2005-04-28
4
Medium Priority
?
1,828 Views
Last Modified: 2008-01-09
Hi,
Im using the following code to copy a file:

Windows.CopyFile(src, dst, false);

How do I wait for the file to be completely copied so that I could run it using shellexecute afterwards? I like simple code =)

Thanks.
0
Comment
Question by:createit
  • 2
4 Comments
 
LVL 4

Expert Comment

by:BedouinDN
ID: 13892489
Windows.CopyFile returns a boolean value.

Check the boolean value before continuing:

0
 
LVL 2

Assisted Solution

by:Ratje
Ratje earned 240 total points
ID: 13892491
Copyfile is a function and returns True or False.
In order to return a value it must have completed the action

So :

if Windows.CopyFile(src, dst, false) then
  //your shellexecute here

will do the trick
0
 
LVL 4

Accepted Solution

by:
BedouinDN earned 260 total points
ID: 13892501
*Blush* forgot that I cant use the TAB key for indentation here :-) (and the space bar will also click the submit button)

    if CopyFile(PChar(srcFile),PChar(destFile)) then
    begin
    //Do Shell execute code here
    end
    else
    begin
    //Copy failed - perform other function
    end;

Regards.
Colin..
0
 

Author Comment

by:createit
ID: 13892606
That is so weird. I tried that earlier and it seemed like the copyfile function just sent a command to copy the file and continued to the rest of my code without waiting for the file to be fully copied...But I just tried it again and it seems like it is waiting now. I have no idea why it wasnt working before...Im going to try it again in the morning with a big file to really determine if its working (after some sleep). If its still working properly (waits until the entire file is copied) Ill split the points between the two of you. Im just so curious on what I might have done differently before that it wasnt giving me the correct results.
Thanks for your help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question