Thread: CreateFile and Long Path/Files :: Win32

  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,138
    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