JSThePatriot Posted May 27, 2005 Posted May 27, 2005 My problem will be described below, but this is my full script.expandcollapse popupDim $search, $file Dim $dirSize, $dirFile Dim $i, $line, $attrib ;Opens the file to write the desired output to. $dirFile = FileOpen("output.txt", 1) If $dirFile = -1 Then MsgBox(0, "Error", "The file output.txt was unable to be opened.") Exit EndIf ; Shows the filenames of all files in the current directory, note that "." and ".." are returned. $search = FileFindFirstFile("C:\*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf ;MsgBox(0, "$search", $search) While 1 $file = FileFindNextFile($search) ;MsgBox(0, "$file", $file) Sleep(10) If @error Then MsgBox(0, "Error", "There are no more files/directories") ExitLoop EndIf $attrib = FileGetAttrib($file) Sleep(10) If @error Then MsgBox(4096,"Error", "Could not obtain attributes.") Exit Else If StringInStr($attrib, "D") Then $dirSize = DirGetSize($file, 1) $line = "Filename: " & $file & " " & "DirSize(MB): " & Round($dirSize[0]/1024/1024) & " " & "NumFiles: " & $dirSize[1] & " " & "NumDirectories: " & $dirSize[2] FileWriteLine($dirFile, $line) EndIf EndIf WEnd ; Close the search handle FileClose($search) FileClose($dirFile)Most of the above code is straight from the help file. All of the If statements that check @error are erroring out, but when I have the Sleep(10) in there it doesnt error, but my program never stops because it never catches the @error function.I did try using a message box to see if it was really erroring out or not, but it showed it really didnt error.$file = FileFindNextFile($search) MsgBox(0, "$file", $file) If @error Then MsgBox(0, "Error", "There are no more files/directories") ExitLoop EndIfWithout the message box that errors everytime. This is copied straight out of the helpfile. I cant help but to think there is something I have done.Any help would be much appreciated.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
GaryFrost Posted May 27, 2005 Posted May 27, 2005 (edited) expandcollapse popupDim $search, $file Dim $dirSize, $dirFile, $dir = "c:\" Dim $i, $line, $attrib ;Opens the file to write the desired output to. $dirFile = FileOpen("output.txt", 1) If $dirFile = -1 Then MsgBox(0, "Error", "The file output.txt was unable to be opened.") Exit EndIf ; Shows the filenames of all files in the current directory, note that "." and ".." are returned. $search = FileFindFirstFile($dir & "*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf ;MsgBox(0, "$search", $search) While 1 $file = FileFindNextFile($search) If @error Then MsgBox(0, "Error", "There are no more files/directories") ExitLoop EndIf $attrib = FileGetAttrib($dir & $file) If $attrib == "" Then MsgBox(4096,"Error", "Could not obtain attributes from " & $file) ;~ Exit Else If StringInStr($attrib, "D") Then $dirSize = DirGetSize($dir & $file, 1) $line = "Filename: " & $file & " " & "DirSize(MB): " & Round($dirSize[0]/1024/1024) & " " & "NumFiles: " & $dirSize[1] & " " & "NumDirectories: " & $dirSize[2] FileWriteLine($dirFile, $line) EndIf EndIf WEnd ; Close the search handle FileClose($search) FileClose($dirFile) Edited May 27, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
JSThePatriot Posted May 27, 2005 Author Posted May 27, 2005 That did it. I guess that should be changed in the helpfile or something. Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
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