Very frequently in the forums, someone posts a question asking for a function that will create a full directory path for them. For example, they may want to create c:\a\b\c\d\e\f with one call, where the intermediate folders may not exist. The answer, if you are on Win 2000 or later, is to use the SHCreateDirectoryEx function that’ll do this for you. Here’s some sample code :
SHCreateDirectoryEx(NULL,
_T("d:\\abc\\def\\ghi\\nish"), NULL);
It’s a really useful API function, just not that well known. Anyway this blog entry will serve as a link which I’ll point to, if I see this question popping up in the forums again.
One tricky thing about that function is that it reutrns ERROR_ALREADY_EXISTS
if you pass it the name of an existing directory *or* file. So if you get that error
back, you have to check the attributes of the path you passed it to make sure it is
really a directory.
Thanks for that bit of info, Mike.
Well thats really a nice information :-rather than recursively calling createdirectory (API)
Thanks for posting the same Dude.