Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get file size in mega bytes

Get file size in mega bytes

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++json
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    big_denny_200
    wrote on last edited by
    #1

    Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ? I have a MFC prpject. thank you.

    T S N 3 Replies Last reply
    0
    • B big_denny_200

      Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ? I have a MFC prpject. thank you.

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      big_denny_200 wrote:

      Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ?

      GetFileSizeEx() for reteriving size of File and convert that into MB by divinding it by 1024 *1024

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

      H 1 Reply Last reply
      0
      • B big_denny_200

        Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ? I have a MFC prpject. thank you.

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        open the file using CFile then call "GetLength" it will give u size in bytes divide it by (1024*1024) ( im not sure this calculation is correct) :) SaRath.
        "Don't Do Different things... Do Things Differently..."

        D 1 Reply Last reply
        0
        • B big_denny_200

          Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ? I have a MFC prpject. thank you.

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          This[^] will help. :)


          Nibu thomas A Developer Programming tips[^]  My site[^]

          1 Reply Last reply
          0
          • T ThatsAlok

            big_denny_200 wrote:

            Hi all :) How can I get file size in mega bytes ? Is there any good API, for this ?

            GetFileSizeEx() for reteriving size of File and convert that into MB by divinding it by 1024 *1024

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Hi ThatsAlok, How are you?:) and StrFormatByteSizeA_**


            **_

            whitesky


            T 2 Replies Last reply
            0
            • H Hamid Taebi

              Hi ThatsAlok, How are you?:) and StrFormatByteSizeA_**


              **_

              whitesky


              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              WhiteSky wrote:

              How are you?:)

              Fine :)

              WhiteSky wrote:

              nd StrFormatByteSizeA

              Will try!

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              • H Hamid Taebi

                Hi ThatsAlok, How are you?:) and StrFormatByteSizeA_**


                **_

                whitesky


                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                WhiteSky wrote:

                StrFormatByteSizeA

                Thanks for Api!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                H 1 Reply Last reply
                0
                • T ThatsAlok

                  WhiteSky wrote:

                  StrFormatByteSizeA

                  Thanks for Api!

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  yo're welcome Mr Alok Gupta :)_**


                  **_

                  whitesky


                  T 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    yo're welcome Mr Alok Gupta :)_**


                    **_

                    whitesky


                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #9

                    WhiteSky wrote:

                    welcome Mr Alok Gupta :)

                    Even Alok will do:)

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                    1 Reply Last reply
                    0
                    • S Sarath C

                      open the file using CFile then call "GetLength" it will give u size in bytes divide it by (1024*1024) ( im not sure this calculation is correct) :) SaRath.
                      "Don't Do Different things... Do Things Differently..."

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      SaRath C wrote:

                      open the file using CFile

                      Not a good idea as Open() is an expensive call, not to mention that it could easily fail if another process has the file open.


                      "The largest fire starts but with the smallest spark." - David Crow

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups