CreateDirectory doesn't work...

I am trying to use the CreateDirectory function to create a directory structure. Is this allowed? For example, I have a directory now called d:\temp. I want to create upto d:\temp\dir1\dir2\dir3 in one go.

I have tried to create even one directory by CreateDirectory seems to fail with the following error message:
"Invalid Access to Memory Location".

My code looks like this:
sAtr.nLength = sizeof(SECURITY_ATTRIBUTES);
BOOL bDirDone = CreateDirectory("d:\\Temp\\dir1\\dir2\\dir3", &sAtr);

Whats going wrong??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hope this helps u out ?
U can't create a number of directory at once, this piece of code would help u ...
The security attributes may be as u specified with any attributes or NULL.
BOOL bDirDone = CreateDirectory("\\?\D:\Temp\dir1",NULL) ;
bDirDone = CreateDirectory("\\?\D:\Temp\dir1\dir2",NULL) ;
bDirDone = CreateDirectory("\\?\D:\Temp\dir1\dir2\dir3",NULL) ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
baigmzAuthor Commented:
I tried this one. Its only a wide format for the file name to enable more than 248 chars in the filename. It doesn't make a difference.
YOu use UNICODE build?

If so
place characters into _T() macro



This should help.
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

sAtr.nLength = sizeof(SECURITY_ATTRIBUTES);

That's all?

Shouldn't it be:

memset(&sAttr, 0, sizeof(sAttr));
sAtr.nLength = sizeof(SECURITY_ATTRIBUTES);

and fill out the structure members
I am sorry baiqmz try this it should work because i have tried this out..

It will create 3 directories .
baigmzAuthor Commented:
Yes, I tried providing no security attributes and it works. The MSDN isn't clear enough.

Thanks anyway.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.