CreateDirectory fails with error 123 when used with a long path

Hi,
I am trying to overcome the MAX_PATH limit on the paths for win32 APIs. As suggested in the msdn documentation for these APIs (i.e. CreateDirectory), I have tried with '\?' pre-pended to the path but keep on getting the error 123.Here is my code -wstring path = L"\\?\D:\";if(!CreateDirectory(path.c_str(), NULL)) //translates to CreateDirectoryW { // Get the error using GetLastError()}Error 123 stands for - “The filename, directory name, or volume label syntax is incorrect.”. Is there something else that i need to do differently?
Regards,Surya

What is your ?

NTFS allows paths upto 32K characters. But each individual directory name is still limited to 255 characters.

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Suryadeep Biswal
Sent: Friday, October 25, 2013 10:43 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] CreateDirectory fails with error 123 when used with a long path

Hi,

I am trying to overcome the MAX_PATH limit on the paths for win32 APIs. As suggested in the msdn documentation for these APIs (i.e. CreateDirectory), I have tried with '\?' pre-pended to the path but keep on getting the error 123.
Here is my code -
wstring path = L"\\?\D:\<file:>";
if(!CreateDirectory(path.c_str(), NULL)) //translates to CreateDirectoryW
{
// Get the error using GetLastError()
}
Error 123 stands for - “The filename, directory name, or volume label syntax is incorrect.”. Is there something else that i need to do differently?

Regards,
Surya


NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</file:>

I was using a directory with more than 255 characters. The issue is gone after i fixed that.
Thanks for the help!

From: xxxxx@McAfee.com
To: xxxxx@lists.osr.com
Subject: RE: [ntfsd] CreateDirectory fails with error 123 when used with a long path
Date: Fri, 25 Oct 2013 17:48:55 +0000

What is your ?

NTFS allows paths upto 32K characters. But each individual directory name is still limited to 255 characters.

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Suryadeep Biswal

Sent: Friday, October 25, 2013 10:43 AM

To: Windows File Systems Devs Interest List

Subject: [ntfsd] CreateDirectory fails with error 123 when used with a long path

Hi,

I am trying to overcome the MAX_PATH limit on the paths for win32 APIs. As suggested in the msdn documentation for these
APIs (i.e. CreateDirectory), I have tried with '\?' pre-pended to the path but keep on getting the error 123.
Here is my code -
wstring path = L"\\?\D:\";
if(!CreateDirectory(path.c_str(), NULL)) //translates to CreateDirectoryW
{
// Get the error using GetLastError()
}
Error 123 stands for - “The filename, directory name, or volume label syntax is incorrect.”. Is there something else that
i need to do differently?

Regards,
Surya



NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:

http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer



NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:

http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Is your app being compiled in Unicode mode? If not, you must explicitly
call CreateDirectoryW. The error you got is certainly consistent with
what I would expect if you called CreateDirectoryA. Note that there is no
CreateDirectory API. It is actually pretty meaningless to say you called
a nonexistent API. You either called. CreateDirectoryA or
CreateDirectoryW, which are the only two APIs that exist (I’m ignoring the
Nt and Zw versions). “CreateDirectory” is an illusion, done with smoke,
mirrors, and #ifdefs.

Joe

Hi,
I am trying to overcome the MAX_PATH limit on the paths for win32 APIs. As
suggested in the msdn documentation for these APIs (i.e. CreateDirectory),
I have tried with '\?' pre-pended to the path but keep on getting the
error 123.Here is my code -wstring path =
L"\\?\D:\";if(!CreateDirectory(path.c_str(), NULL))
> //translates to CreateDirectoryW { // Get the error using
> GetLastError()}Error 123 stands for - “The filename, directory name, or
> volume label syntax is incorrect.”. Is there something else that i need to
> do differently?
> Regards,Surya
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer