ChrisL Posted February 16, 2009 Posted February 16, 2009 I need to monitor a directory to see when it has some files copied in to it, but I need to be sure the file copy has finished. I tried using dirgetsize() in a loop but this doesn't work. When the filecopy starts Windows allocates the finished size to the directory. So if its a large file that takes 30 seconds to copy in the directory size is aready showing the final size each check. Is there an alternative method? Thanks [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Zohar Posted February 16, 2009 Posted February 16, 2009 I donno how to do it in AutoIt,But Do you know C#?In C#(.NET generally) you can use a component called System.IO.FileSystemWatcher.What you can do is write the Waiting function in C#, compile it to an EXE,and then use RunWait() in your AutoIt code, to run it and wait for it.
Manjish Posted February 16, 2009 Posted February 16, 2009 (edited) can't u just see if the directory has that file or not.. by _FileListToArray.. just search for file's name in there Edited February 16, 2009 by Manjish [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Manjish Posted February 16, 2009 Posted February 16, 2009 or easier still.. just see if the "Copying.." window exists or not.. by WinExists [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
ChrisL Posted February 16, 2009 Author Posted February 16, 2009 Well Thanks for the replies, but the best method I have found so far is to use Func _FileOpenAPI($sFile) Local $GENERIC_READ = 0x80000000, $GENERIC_WRITE = 0x40000000, $OPEN_ALWAYS = 4, $FILE_ATTRIBUTE_NORMAL = 0x00000080, $FILE_SHARE_NONE = 0x00000000, $FILE_SHARE_READ = 0x00000001, $FILE_SHARE_WRITE = 0x00000002 Local $AFO_h $AFO_h = DllCall("kernel32.dll", "hwnd", "CreateFile", "str", $sFile, "long", BitOR($GENERIC_READ, $GENERIC_WRITE), "long", $FILE_SHARE_NONE, "ptr", 0, "long", $OPEN_ALWAYS, "long", $FILE_ATTRIBUTE_NORMAL, "long", 0) Return $AFO_h[0] EndFunc ;==>_FileOpenAPI Using the "File_Share_None" flag and check each file in the directory to make sure I can open it. It fails to open if it is mid copy. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now