Jump to content

Filegetsize returns 0


Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...