Thread: File questions

  1. #1
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109

    File questions

    how would i tell would files are in a folder and how big a file is?
    int a; don't make a program without it.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    This is OS specific... if you're on windows, to get a file's size use GetFileSize() or GetFileSizeEx()
    To list a directory, use FindFirstFile, FindNextFile and FindClose API functions. Look them up on msdn.microsoft.com if you need more help.

  3. #3
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    thanks
    int a; don't make a program without it.

  4. #4
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    If you're not using Windows you can use the <io.h> _findfirst, _findnext and _findclose functions. With them (the first 2 at least, the 3rd is use to clean-up when you're done) you load the files' info into a _finddata_t structure which holds the file's attribute(s), creation/access/write times, size and name. You can find info on all this on MSDN, too.

  5. #5
    Registered User Josh Kasten's Avatar
    Join Date
    Jul 2002
    Posts
    109
    thanks
    int a; don't make a program without it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM