Get filesize in megabytes RRS feed

  • Question

  • Is there a function to get the size of a file in megabytes within the framework?
    Thursday, November 30, 2006 2:20 PM


All replies

  • no there isnt, you would have to create the calc/conversion. you will get the filesize in length (KB) which then you need to convert to MB

    1024KB = 1MB

    Thursday, November 30, 2006 2:22 PM
  • The System.IO.FileInfo.Length property will give you the file size in bytes. Divide by 1,048,576 (1024 x 1024) to get the size in megabytes.


    --Ian Nelson
    Thursday, November 30, 2006 2:27 PM