Create a directory
-
Hi CPians, following code does work:
BOOL b4=CreateDirectory("C:\\hop",NULL);
following does not work (I have deleted the hop previously created by the previous code line, so the start point is the same):
BOOL b4=CreateDirectory("C:\\hop\\hop\\hop",NULL);
GetLastError returns 3, which states "The system cannot find the path specified." which is in this especially true, since I would like to create the directory :rolleyes: Does
CreateDirectory
not support multiple level creation ? If not, are there any alternative solution to it ? Do I have to use specific security attributes ? If yes, how can I retrieve them (like the ones currently set for the system) ? Do you think following is possible withCreateDirectory
:BOOL b4=CreateDirectory("\\server.hop.com\\hop\\hop",NULL);
Thanks for all ~RaGE();
-
Hi CPians, following code does work:
BOOL b4=CreateDirectory("C:\\hop",NULL);
following does not work (I have deleted the hop previously created by the previous code line, so the start point is the same):
BOOL b4=CreateDirectory("C:\\hop\\hop\\hop",NULL);
GetLastError returns 3, which states "The system cannot find the path specified." which is in this especially true, since I would like to create the directory :rolleyes: Does
CreateDirectory
not support multiple level creation ? If not, are there any alternative solution to it ? Do I have to use specific security attributes ? If yes, how can I retrieve them (like the ones currently set for the system) ? Do you think following is possible withCreateDirectory
:BOOL b4=CreateDirectory("\\server.hop.com\\hop\\hop",NULL);
Thanks for all ~RaGE();
The documentation for CreateDirectory[^] does mention that it will only create the final directory in the specified path (c.f. the comments for ERROR_PATH_NOT_FOUND). There is a suggestion at the MSDN site to use the SHCreateDirectoryEx function. However, the documentation for this function would indicate that it won't work on earlier versions of Windows. The alternative is to parse your path string (for the '\\' or '/' characters) and create the intermediate directories as well. You can use CString to locate the first occurrence of the character, do a SetCurrentDirectory and, if that fails, CreateDirectory. Repeat this process until you've parsed all subdirectories in the path string. Bob Ciora