CreateFile and Long Path/Files :: Win32

This is a discussion on CreateFile and Long Path/Files :: Win32 within the Windows Programming forums, part of the Platform Specific Boards category; Hi. Is it possible to create a file with a long path name? For example: Code: std::string pathFile("c:\testing\December 27\newfile.type"); // ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    CreateFile and Long Path/Files :: Win32

    Hi.

    Is it possible to create a file with a long path name? For example:

    Code:
    std::string pathFile("c:\testing\December 27\newfile.type");
    
    // CreateFile fails
    if (::CreateFile(pathFile->c_str(),...) == INVALID_HANDLE_VALUE)
    {
    }
    I would like to know two properties of CreateFile(). First, is it possible to create a file in a directory that does not exist via CreateFile()? In the example above, directories "testing" and "December 27" do not exist.

    Secondly, is it possible to create directories with spaces between one or more words, i.e. December 27. Notice the space before "2."

    Thanks,
    Kuphryn

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    Yes, no and yes. MSDN has the answers.
    Joe

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Is there a Win32 API for checking the existence of a directory? Otherwise, recursive creation will do.

    One last inquiry. I have seen in the past members mentioning directories with two backslashes. Is there something special about creating directories with two backslashes instead of one?

    Example:
    std::string pathFile("c:\\testing\\December 27\\file.type");

    Kuphryn

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    You have to use \\ or /. A single \ followed by a character is interpretted as an escape code.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. Thanks.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateFile() giving errors
    By neandrake in forum Windows Programming
    Replies: 2
    Last Post: 09-27-2004, 10:29 PM

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