PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[Resolved] converting filesize-VBForums
Results 1 to 7 of 7

Thread: [Resolved] converting filesize

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    54

    Resolved [Resolved] converting filesize

    Hello,

    When i will try to get the filesize of a file, i am getting it in the format of

    4532
    197
    832
    52
    etc

    Is it possible that i will return the filesize in KB, or MB ?

    Thank You
    Last edited by Moxxu; Jul 8th, 2005 at 06:05 AM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    11,038

    Re: converting filesize

    Those are probably KB. Have you compared it with the file's properties?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    54

    Re: converting filesize

    no, i think they are bytes, here are the four actual file sizes:

    4.43KB
    837 bytes
    197 bytes
    51 bytes

    Thank You

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    11,038

    Re: converting filesize

    Have you used FileLen?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    54

    Re: converting filesize

    the filelen, still gave me the results in bytes:

    4539
    197
    839
    51

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: converting filesize

    I don't expect there will be a way to change how it returns the size but its easy to convert:

    VB Code:
    1. ByteSize = 4539
    2. KiloSize = ByteSize / 1024
    3. MegaSize = ByteSize / KiloSize / 1024
    4.  
    5. 'Or...
    6.  
    7. ByteSize = 4539
    8.  
    9. If ByteSize > 1024 Then
    10.     KiloSize = ByteSize / 1024
    11.     If KiloSize > 1024 Then
    12.         MegaSize = KiloSize / 1024
    13.         Debug.Print MegaSize & "MB"
    14.     Else
    15.         Debug.Print KiloSize & "KB"
    16.     End If
    17. Else
    18.     Debug.Print ByteSize & "bytes"
    19. End If
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    54

    Re: converting filesize

    Thank you for your guide.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width