Thread: Checking the directory

  1. #1

    Checking the directory

    Hi all!

    I'm a bit stuck here, so...

    I'd need to check if a certain directory exists (on win2000 server), and if it doesn't, it should be created. The name of the directory could be anything, it comes from a variable. How can I do that check? And will I need a batch file to create the folder (passing the folder name as a parameter to it), or can system commands such as md be used with a variable?
    (e. g. system( "md" folder_name ) // this doesn't work, I know).

    I'm using Visual C++ on win2000.

    Any help would be greatly appreciated.

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    You could call the API function SetCurrentDirectory(yourfullpath) and if this fails then call CreateDirectory(yourfullpath,NULL);

    Both these functions are in windows.h.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  3. Checking Directory and then Compiling
    By srm2888 in forum C Programming
    Replies: 6
    Last Post: 02-28-2008, 06:57 PM
  4. Problems about gcc installation
    By kevin_cat in forum Linux Programming
    Replies: 4
    Last Post: 08-09-2005, 09:05 AM
  5. Directory reading trouble
    By samGwilliam in forum Linux Programming
    Replies: 0
    Last Post: 03-10-2002, 09:43 AM