stampy Posted February 8, 2009 Share Posted February 8, 2009 One of my scripts is not running correctly under Vista. It simply downloads a file then while the file is downloading reports the file size. After some research I've found that the FileGetSize function seems to not work correctly in Vista. In XP it works fine. But in Vista it seems to rely on a cached size. I created the following sample as a test. When running on Vista it'll report the same size repeatedly. It will change at the beginning then stop changing. However if I open or refresh explorer on that directory, it'll then allow the FileGetSize to see the new size. (can be seen with the gui set up in the background, when I refresh the explorer window the GUI will change). It'll also see the new size if I use another script and call the file size. I'm not very good on Vista. Does anyone know if there is a way around this? #include <GUIConstantsEx.au3> $url = 'http://download.microsoft.com/download/6/0/f/60fc5854-3cb8-4892-b6db-bd4f42510f28/dotnetfx35.exe' $file = @DesktopDir & '\xyz.xyz' InetGet($url,$file,0,1) GUICreate("My GUI") ; will create a dialog box that when displayed is centered $label=GUICtrlCreateLabel('',10,10,400,200) GUISetState() Do Sleep(10) GUICtrlSetData($label,FileGetSize($file)) $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 8, 2009 Share Posted February 8, 2009 GileGetSize() work correctly, but as you have discovered it won't work for checking files while they are downloading. You should use @InetGetBytesRead instead. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
stampy Posted February 8, 2009 Author Share Posted February 8, 2009 My problem, that this example doesn't show, is that in my full script I'm using an outside program to control the download and not using Inetget(). I was just using GetFileSize() to know how far along I was. Now I'm just trying to figure out how to solve this on Vista as it's always worked on XP. Link to comment Share on other sites More sharing options...
Intruder Posted March 16, 2009 Share Posted March 16, 2009 (edited) My problem, that this example doesn't show, is that in my full script I'm using an outside program to control the download and not using Inetget(). I was just using GetFileSize() to know how far along I was. Now I'm just trying to figure out how to solve this on Vista as it's always worked on XP.I ran into the same problem, but I solved it with good old DOS techniques, where the output is not cached by Vista.Func MyFileGetSize( $file ) ; " are used to deal with files and directories containing spaces ; @SW_ HIDE is used to avoid flickering shell windows ; for-command used for quicker access to filesize instead of parsing dir-command, for details see for /? RunWait( @Comspec & ' /c for %f in ("' & $file & '" ) do echo %~zf>%TEMP%\MyFileGetSize.tmp', '', @SW_HIDE ) Dim $fh = FileOpen( @TempDir & '\MyFileGetSize.tmp', 0 ) Dim $line = FileReadLine( $fh ) FileClose( $fh ) FileDelete( @TempDir & '\MyFileGetSize.tmp' ) Return( $line )EndFuncOf course, currently there is no error handling in this function. So if you want it bulletproof, add some checks by yourself.Cheers Intruder Edited March 16, 2009 by Intruder Link to comment Share on other sites More sharing options...
MegaGamerGuy Posted August 13, 2011 Share Posted August 13, 2011 i found a fix that might work for ya... i think the issue has something to do with windows search thingy, ever notice how when you browse a folder and u see the green progress bar in the address bar of the folder ur in? i remember that if i cancel that my files dont show up. this means that windows isnt keeping track of the files when a folder is open, but intsead only when you manually update it. $handel = FileOpen($filename, 1) ; Read Only FileFlush($handel) ; causes windows to flush it's cache and update the information FIleClose($handel) ; closes the file FileGetSize($filename) thar u go Link to comment Share on other sites More sharing options...
MegaGamerGuy Posted August 16, 2011 Share Posted August 16, 2011 i found a fix that might work for ya...i think the issue has something to do with windows search thingy, ever notice how when you browse a folder and u see the greenprogress bar in the address bar of the folder ur in? i remember that if i cancel that my files dont show up. this means thatwindows isnt keeping track of the files when a folder is open, but intsead only when you manually update it.$handel = FileOpen($filename, 1) ; Read OnlyFileFlush($handel) ; causes windows to flush it's cache and update the informationFIleClose($handel) ; closes the fileFileGetSize($filename)thar u go Well seems I may have found a bug in autoit dealing with FileFlush()it may not be a good idea to use this to manually update the filesize in win7 X86 anyways :S Link to comment Share on other sites More sharing options...
monoscout999 Posted August 16, 2011 Share Posted August 16, 2011 you did`t read the whole thread, a thread of two years old... you are pissing outside the jar, posting this as a bug, without considering what other advanced members have to say Link to comment Share on other sites More sharing options...
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