CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2001
    Posts
    251

    Exclamation Creating deep directories

    I'm trying to create a file for writing:

    FILE *File = fopen( "C:\\some\\really\\deep\\directory\\blah.dat", "rb" );


    The only problem is, none of these subdirectories exist, so fopen fails.

    Is there a simple way to create all of these directories, when trying to
    write a file?

    Is there a general command to create deep directories that don't exist,
    using just a single string of those sub-directories?

    yeah, I can probably write up a hack to handle cases like this,
    but I would rather use something that already does it if there is one.
    Last edited by Syslock; December 18th, 2003 at 11:49 PM.

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Creating deep directories

    Originally posted by Syslock
    Is there a general command to create deep directories that don't exist,
    using just a single string of those sub-directories?
    Well...not to my knowledge...you have to do it one by one...

  3. #3
    Join Date
    Sep 2003
    Location
    Forever Gone... For Now...
    Posts
    1,515

    Re: Creating deep directories

    SHCreateDirectoryEx might work for you...
    Thought for the day/week/month/year:
    Windows System Error 4006:
    Replication with a nonconfigured partner is not allowed.

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Re: Creating deep directories

    Originally posted by vicodin451
    SHCreateDirectoryEx might work for you...
    Cool....I guess I have to take a deeper look at the shell functions (which I tried to avoid for a long time)...

  5. #5
    Join Date
    Nov 2001
    Posts
    251
    This function creates a file system folder whose fully qualified path is given by pszPath. If one or more of the intermediate folders do not exist, they will be created as well.
    That's sounds like exactly what I need. Thanks.

  6. #6
    Join Date
    Sep 2003
    Posts
    90
    Minimum operating systems Windows 2000, Windows Millennium Edition

  7. #7
    Join Date
    Sep 2003
    Location
    Forever Gone... For Now...
    Posts
    1,515
    Originally posted by kallzz
    Minimum operating systems Windows 2000, Windows Millennium Edition
    That's why I said might...
    Thought for the day/week/month/year:
    Windows System Error 4006:
    Replication with a nonconfigured partner is not allowed.

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