Sign in to follow this  
Followers 0
Stretch

Filegetsize returns 0

5 posts in this topic

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I expect it to show 0 for directories, but it shows 0 for files aswell.......

Share this post


Link to post
Share on other sites

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)


[center]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.[/center]

Share this post


Link to post
Share on other sites

COCK! :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0