Detect disk activity in Delphi

前端 未结 4 638
闹比i
闹比i 2020-12-28 23:49

I\'m using Delphi 2007.

I am copying files to a remote drive. When the copying ends, I shutdown/standby the machine. It can happen that some files don\'t get copied

4条回答
  •  感动是毒
    2020-12-29 00:29

    (Please move the additional information from the comment to your question.) AFAIK there is no Windows API to tell whether all data has been written to disk.

    What you are looking for is the Windows equivalent of the Unix sync command. You could run this tool from your program. Please read the information on the linked page, this requires administrative rights, and even so it may not be enough to be sure - some disk drives have a firmware that tells the OS that all writes have completed, when in fact they have not, and unwritten data is still in the on-disk-cache. You should better add a delay after your copy action has finished, to be on the safe side.

提交回复
热议问题