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. how to get the size of the file

how to get the size of the file

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 5 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.
  • K Offline
    K Offline
    keerthikaaa
    wrote on last edited by
    #1

    hai everybody I have a problem in retrieving the size of the file.i have to monitor the directory and i have to show the filr name ,file size and date and time of file which is monitored.here i want to know how can i retrieve the size of the file.is there any function which can be used to retrieve that one. If any body knows help me to get it done. :)

    N A Y 3 Replies Last reply
    0
    • K keerthikaaa

      hai everybody I have a problem in retrieving the size of the file.i have to monitor the directory and i have to show the filr name ,file size and date and time of file which is monitored.here i want to know how can i retrieve the size of the file.is there any function which can be used to retrieve that one. If any body knows help me to get it done. :)

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      keerthikaaa wrote:

      is there any function which can be used to retrieve that one.

      GetFileSize() nave

      1 Reply Last reply
      0
      • K keerthikaaa

        hai everybody I have a problem in retrieving the size of the file.i have to monitor the directory and i have to show the filr name ,file size and date and time of file which is monitored.here i want to know how can i retrieve the size of the file.is there any function which can be used to retrieve that one. If any body knows help me to get it done. :)

        A Offline
        A Offline
        Aqueel
        wrote on last edited by
        #3

        Do something like that, int fh = _open("myfile.txt", _O_APPEND , _S_IREAD | _S_IWRITE ); int filesize = _filelength(fh); if (filesize == 0) {do something} This requires following header files 1. io.h 2. fcntl.h 3. sys\stat.h Good luck We Believe in Excellence www.aqueelmirza.cjb.net

        1 Reply Last reply
        0
        • K keerthikaaa

          hai everybody I have a problem in retrieving the size of the file.i have to monitor the directory and i have to show the filr name ,file size and date and time of file which is monitored.here i want to know how can i retrieve the size of the file.is there any function which can be used to retrieve that one. If any body knows help me to get it done. :)

          Y Offline
          Y Offline
          YaronNir
          wrote on last edited by
          #4

          An other approach is to use FindFirstFile, and then the structure WIN32_FIND_DATA is filled with the file size as follows: The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow. both nFileSizeHigh and nFileSizeLow are members of the structure WIN32_FIND_DATA. Yaron Ask not what your application can do for you, Ask what you can do for your application

          N 1 Reply Last reply
          0
          • Y YaronNir

            An other approach is to use FindFirstFile, and then the structure WIN32_FIND_DATA is filled with the file size as follows: The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow. both nFileSizeHigh and nFileSizeLow are members of the structure WIN32_FIND_DATA. Yaron Ask not what your application can do for you, Ask what you can do for your application

            N Offline
            N Offline
            Nishad S
            wrote on last edited by
            #5

            This is the better method, because the file should be opened in those solution sent by other guys. - NS -

            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