Help Creating a Folder

This is a discussion on Help Creating a Folder within the C++ Programming forums, part of the General Programming Boards category; I'm a novice programmer who uses MetroWerks CodeWarrior. My current project calls for me to create a folder through the ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    2

    Help Creating a Folder

    I'm a novice programmer who uses MetroWerks CodeWarrior. My current project calls for me to create a folder through the console. I've tried stdlib.h's system function (system ("md directory")), but this does not seem to work (most likely because of CodeWarrior). Is there another way? Thanks in advance!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    ::Assuming Windows Platform::

    CreateDirectory("C:\\MyNewFolder",NULL);

    And include windows.h

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    #include <direct.h> and you can use int _mkdir(const char *pathname);

    Sooo...
    _mkdir("C:\\My Folder");

    You can check up here: http://www.digitalmars.com/rtl/direct.html#_mkdir for extended information. Best of all, its portable.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    2
    Where do I find direct.h (and the .cpp for the matter)? It doesn't seem to be part of my standard library.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Apotheosis
    Where do I find direct.h (and the .cpp for the matter)? It doesn't seem to be part of my standard library.
    Yup...and you know what??? There is no standard way to create a directory...

    So use a compiler supplied method (Eibro's suggestion works on DigitalMars)....or if you are working on windows, use an API call like I suggested

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Hmm, the way I suggested also works under VC++ 6... and as the website says "DOS Windows 3.x Phar Lap DOSX Win32"

    I figured that would mean all Win32 compilers would have direct.h... ah well.

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, 10:38 AM
  2. creating a new folder at the start of every day
    By shoobsie in forum C Programming
    Replies: 9
    Last Post: 06-23-2005, 09:10 AM
  3. Creating a Folder
    By Junior89 in forum C++ Programming
    Replies: 9
    Last Post: 11-07-2004, 12:45 AM
  4. Creating a Folder
    By Wanted420 in forum C++ Programming
    Replies: 2
    Last Post: 06-19-2003, 11:44 AM
  5. Creating a folder then dumping files into it!
    By ChrisMUK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 08-13-2002, 04:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21