Thread: Question

  1. #1
    Registered User snowy101's Avatar
    Join Date
    May 2002

    Lightbulb Question

    If there a way to scan a folder for names that are in .txt format that you do not know the name for. i use c++ borland vrs 5. and i would like to know how to do this. if you need any detailed info about this question send me an e-mail.

    when candy is made so is a smile

  2. #2
    Registered User
    Join Date
    Jun 2002
    If you want to scan for filenames then use the windows functions FindFirstFile and FindNextFile.

    eg, get all .txt files in the c:\ directory
    #include <windows.h>
    #include <iostream.h>
    int main(void)
    	WIN32_FIND_DATA file;
    	HANDLE nextfile;
    	BOOL res;
    	// get info on a file
    	nextfile = FindFirstFile("c:\\*.txt", &file);
    		cout << file.cFileName << endl;
    		// get info on next file
    		res = FindNextFile(nextfile, &file);
    	} while(res);
    	return 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM