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

Thread: Creating a Directory

  1. #1
    Join Date
    Jun 2003
    Posts
    190

    Creating a Directory

    Is there a certain command that will allow you to create a new directory?

    I want the user to enter a name of a directory, and when he clicks "create directory" it makes a directory.

    For example if he typed "pictures", it would get the current path name and then create a folder called "pictures".

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    One solution is CreateDirectory().

    Kuphryn

  3. #3
    Join Date
    Jun 2000
    Location
    Phoenix, AZ
    Posts
    35
    One more way is to

    #include <direct.h>

    _mkdir( strDirectoryPath );

    - Chetan.

  4. #4
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: Creating a Directory

    I am not able to create a directory having the following time and date format "Data MM/DD/YYYY - HH:MM:SS".

    It fails when we have characters like "/" and ":" in the directory name. any idea how to resolve this.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,400

    Re: Creating a Directory

    Quote Originally Posted by vcdebugger View Post
    I am not able to create a directory having the following time and date format "Data MM/DD/YYYY - HH:MM:SS".

    It fails when we have characters like "/" and ":" in the directory name. any idea how to resolve this.
    All operating systems have restrictions around what are valid file path characters. If / and : aren't allowed, don't use them, and replace them with something else.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,602

    Re: Creating a Directory

    Quote Originally Posted by vcdebugger View Post
    I am not able to create a directory having the following time and date format "Data MM/DD/YYYY - HH:MM:SS".

    It fails when we have characters like "/" and ":" in the directory name. any idea how to resolve this.
    Slashes are used as directory delineators in a path name. It's not reasonable to expect to be able to use them as part of a directory name.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,848

    Re: Creating a Directory

    Quote Originally Posted by GCDEF View Post
    Slashes are used as directory delineators in a path name. ...
    ... as well as colons that are used as the "drive" delimiters ...
    Last edited by VictorN; November 15th, 2020 at 04:44 AM. Reason: typo
    Victor Nijegorodov

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,320

    Re: Creating a Directory

    Colon is also used to name an alternate NTFS file stream. See http://www.flexhex.com/docs/articles...-streams.phtml
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.8.2)

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)