Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Windows Explorer (SP2)

    I have a Word document which I need to update with a table containing information about various files in a directory. I am using the FileSystemObject to obtain the file details, but I am having problems reconciling the File.Size returned by the FileSystemObject , and Size shown in Windows Explorer.

    I am aware of how to right-click on the file to get the Properties/Size & Size on Disk, but I cannot make sense of how Explorer handles the various values ofr file size. Here are the details of 6 sample files :

    <table border=1><td valign=bottom></td><td valign=bottom>Explorer</td><td valign=bottom>Size</td><td valign=bottom>Size on disk</td><td valign=bottom>File 1</td><td align=right valign=bottom>28</td><td align=right valign=bottom>27.41</td><td align=right valign=bottom>28.00</td><td valign=bottom>File 2</td><td align=right valign=bottom>2</td><td align=right valign=bottom>1.02</td><td align=right valign=bottom>4.00</td><td valign=bottom>File 3</td><td align=right valign=bottom>53</td><td align=right valign=bottom>52.71</td><td align=right valign=bottom>56.00</td><td valign=bottom>File 4</td><td align=right valign=bottom>20</td><td align=right valign=bottom>19.27</td><td align=right valign=bottom>20.00</td><td valign=bottom>File 5</td><td align=right valign=bottom>4</td><td align=right valign=bottom>3.12</td><td align=right valign=bottom>4.00</td><td valign=bottom>File 6</td><td align=right valign=bottom>4</td><td align=right valign=bottom>3.04</td><td align=right valign=bottom>4.00</td></table>


    Can anybody explain exactly how these figures are all derived ?

    All I want to achieve is a colum in at able which replicates the file sizes in Explorer. I though this might be straightforward - I am rapidly learning the error of my thinking.

    Any help gratefully received

    Nick

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Windows Explorer (SP2)

    Your column Size contains the actual file size in KB.

    For display reasons, Explorer rounds this up to the nearest integer (i.e. the smallest integer that is greater than or equal to the file size).

    Space on your hard disk is allocated in units of 4 KB, so even if a file is only 3 bytes, it occupies 4 KB on disk. The column Size on disk rounds up the file sizes to the nearest multiple of 4.

    Say that the size of a file as returned by FileSystemObject is in a variable dblSize. You can use -Int(-dblSize / 1024) to get the size rounded up to the nearest KB.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Windows Explorer (SP2)

    Hans

    As always, you are a star. Thanks for your help.

    Good luck for your boys against Argentina this week (assuming you like football, & even if you don't)

    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •