CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: make directory

  1. #1
    Join Date
    Mar 2003
    Posts
    17

    make directory

    Hello All ,
    I was wondering how i could write to a new directory using "ofstream " .

    eg., ..\\twist\\temp.txt where twist is the directory to be created and "temp.txt" is created using ofstream.

    Also does anybody have some info on using absolute
    and relative paths in c++,would be quite a help.

    Peace 2 all ,
    Umesh

  2. #2
    Join Date
    Jun 2002
    Posts
    1,417
    as far as I know you can't use fstream to create a directory. you have to use other functions, e.g. mkdir() or CreateDirectory() (windows OS).

  3. #3
    Join Date
    Mar 2003
    Posts
    17

    hi stober

    hi Stober,
    Nope,I need my programe to work in other OS too,so Can't use the stuff u sujjested.
    Thanks
    Umesh

  4. #4
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    You will have to either use portable functions or #ifdef for the
    OS-specific code. I think that mkdir() should be available almost
    everywhere. If it's not available on a system, you'll have to do
    OS-specific code then.

    --Paul

  5. #5
    Join Date
    Mar 2003
    Location
    China
    Posts
    10
    why don't you use mkdir?

    under windows :
    #include <direct.h>
    _mkdir(path) ;
    under unix:
    #include <sys/stat.h>
    mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO);
    Speed up! Speed up! Speed up!

    It can be faster!!!

  6. #6
    Join Date
    Mar 2003
    Posts
    17

    brapler thanks

    brapler Thanks a lot ,
    dont worry about the lingo it was clear enough.

    have a lovely weekend,
    Regards,
    Umesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured