Jump to content

Recommended Posts

Posted

hello

Why does this script return 0 for filegetsize?

#include <Array.au3>
Dim $avArray[1]
$search = FileFindFirstFile("c:\*.*")


If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $size=FileGetSize($file)
    
;_ArrayAdd( $avArray,$file&"      "&$size)
    
    MsgBox(4096, "File:", $file&"    "&$size)
WEnd

FileClose($search)

Any ideas?

Posted

It probably shows 0 for directories ...

There is also : DirGetSize

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
  • Moderators
Posted

Your not using the path to the file, only the file name is why you are getting a "0"... You're MsgBox() should show you that, it only shows the name.

#include <Array.au3>
Dim $avArray[1]
$search = FileFindFirstFile(@HomeDrive & "\*.*")


If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $file = @HomeDrive & '\' & $file
    If StringInStr(FileGetAttrib($file), 'D') Then
        $size = Int((DirGetSize($file) / 1024)) & ' kbs'
    Else
        $size = Int((FileGetSize($file) / 1024)) & ' kbs'
    EndIf
    
;_ArrayAdd( $avArray,$file&"      "&$size)
    
    MsgBox(4096, "File:", $file&"     "&$size)
WEnd

FileClose($search)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...