Creating Sub folder
-
Hello all, I want to check for some folder c:\\a\\b and create if that folders does not exits. Till now I have done with checking and creating the c:\\a Can anyone help me hw to create the sub folder along with the main folder. I am using below code.
= "C:\\A”; ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); }if I give= “C:\\A\\B\\”;this code has no effect . -
Hello all, I want to check for some folder c:\\a\\b and create if that folders does not exits. Till now I have done with checking and creating the c:\\a Can anyone help me hw to create the sub folder along with the main folder. I am using below code.
= "C:\\A”; ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); }if I give= “C:\\A\\B\\”;this code has no effect .one way use of
PathFileExists
to check its exist or no(you use of it) (2) you can use ofFindFirstFile/FindNext
(3) if you have folders name you can use ofSetCurrectDirectory();
and check return value of it 0 or 1Suresh H wrote:
“C:\\A\\B\\”;
"C:\\A\\B"
WhiteSky
-
Hello all, I want to check for some folder c:\\a\\b and create if that folders does not exits. Till now I have done with checking and creating the c:\\a Can anyone help me hw to create the sub folder along with the main folder. I am using below code.
= "C:\\A”; ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); }if I give= “C:\\A\\B\\”;this code has no effect .Suresh H wrote:
= “C:\\A\\B\\”; this code has no effect .Path up to parent directory should be valid to make call to
CreateDirectory
succesfull. In your case, folder 'A' should be present to create folder 'B' in it.Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hello all, I want to check for some folder c:\\a\\b and create if that folders does not exits. Till now I have done with checking and creating the c:\\a Can anyone help me hw to create the sub folder along with the main folder. I am using below code.
= "C:\\A”; ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); }if I give= “C:\\A\\B\\”;this code has no effect . -
I was trying to create main and sub folder at a time so that was the problem Now I changed my code as below , now its working correctly..
= "C:\\A"; char buf1[ ] = "C:\\A\\B” ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); CreateDirectory(buf1,NULL); }Thank you WhiteSky , brahmma & Prasad for yr help. -
I was trying to create main and sub folder at a time so that was the problem Now I changed my code as below , now its working correctly..
= "C:\\A"; char buf1[ ] = "C:\\A\\B” ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); CreateDirectory(buf1,NULL); }Thank you WhiteSky , brahmma & Prasad for yr help.One question you want to use of
= "C:\\A";
= "C:\\A\\B"
= "C:\\A\\B\\C"
...
...
= "C:\\A\\B\\C\\...T"
WhiteSky
-
One question you want to use of
= "C:\\A";
= "C:\\A\\B"
= "C:\\A\\B\\C"
...
...
= "C:\\A\\B\\C\\...T"
WhiteSky
-
if you know folers name use of String Table of course before this if your folders are like a b c d...ab ac dc,... use of numbers and convert numbers with
itoa or CString::Format
forPathFileExists
then you can check and create 28 folder with a loop (I think you use of a b c d),but if you different names use of String Table and insert folders name on it and read of it ;)
WhiteSky
-
I was trying to create main and sub folder at a time so that was the problem Now I changed my code as below , now its working correctly..
= "C:\\A"; char buf1[ ] = "C:\\A\\B” ret = PathFileExists(buf); if(ret == 0) { CreateDirectory(buf,NULL); CreateDirectory(buf1,NULL); }Thank you WhiteSky , brahmma & Prasad for yr help.That is some dumb way of doing things. What if you have a 14 folders intermediate to create the innermost folder? Use
SHCreateDirectory()
orSHCreateDirectoryEx()
instead.SHCreateDirectory(NULL, TEXT("D:\\Hi there\\Good luck"));
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
if you know folers name use of String Table of course before this if your folders are like a b c d...ab ac dc,... use of numbers and convert numbers with
itoa or CString::Format
forPathFileExists
then you can check and create 28 folder with a loop (I think you use of a b c d),but if you different names use of String Table and insert folders name on it and read of it ;)
WhiteSky
-
if you know folers name use of String Table of course before this if your folders are like a b c d...ab ac dc,... use of numbers and convert numbers with
itoa or CString::Format
forPathFileExists
then you can check and create 28 folder with a loop (I think you use of a b c d),but if you different names use of String Table and insert folders name on it and read of it ;)
WhiteSky
-
That is some dumb way of doing things. What if you have a 14 folders intermediate to create the innermost folder? Use
SHCreateDirectory()
orSHCreateDirectoryEx()
instead.SHCreateDirectory(NULL, TEXT("D:\\Hi there\\Good luck"));
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
Hi brahmma, I am getting undeclared identifier, we have to include any header or lib file ??? SHCreateDirectory(NULL, TEXT("C:\\A\\B\\C")); SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C")); error C2065: 'SHCreateDirectory' : undeclared identifier error C2065: 'SHCreateDirectoryEx' : undeclared identifier
-
Hi brahmma, I am getting undeclared identifier, we have to include any header or lib file ??? SHCreateDirectory(NULL, TEXT("C:\\A\\B\\C")); SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C")); error C2065: 'SHCreateDirectory' : undeclared identifier error C2065: 'SHCreateDirectoryEx' : undeclared identifier
Suresh H wrote:
we have to include any header or lib file ???
#include "shlobj.h"
and you need to link to shell32.lib
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
That is some dumb way of doing things. What if you have a 14 folders intermediate to create the innermost folder? Use
SHCreateDirectory()
orSHCreateDirectoryEx()
instead.SHCreateDirectory(NULL, TEXT("D:\\Hi there\\Good luck"));
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
Good one !
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Suresh H wrote:
we have to include any header or lib file ???
#include "shlobj.h"
and you need to link to shell32.lib
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
hi Brahmma , I added shell32.lib to project settings, but still i am getting the same error and also i ahve included #include "shlobj.h" . can u plz tell me what is the cause ??
I think you need to download the latest Platform SDK.
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
I think you need to download the latest Platform SDK.
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
Hi brahmma, I am getting undeclared identifier, we have to include any header or lib file ??? SHCreateDirectory(NULL, TEXT("C:\\A\\B\\C")); SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C")); error C2065: 'SHCreateDirectory' : undeclared identifier error C2065: 'SHCreateDirectoryEx' : undeclared identifier
Suresh H wrote:
SHCreateDirectory(NULL, TEXT("C:\\A\\B\\C")); SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C"));
SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C")); There is a third parameter to the
Ex
version of this function! Did you not even look at this function in the documentation? theEx
version of this function allows you to define security attributes to the folder that you create. That is the third parameter while using theEx
version and that is the only difference betweenSHCreateDirectory()
andSHCreateDirectoryEx()
. If you do not want to define security attributes, then do not use theEx
version.
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
Suresh H wrote:
SHCreateDirectory(NULL, TEXT("C:\\A\\B\\C")); SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C"));
SHCreateDirectoryEx(NULL, TEXT("C:\\A\\B\\C")); There is a third parameter to the
Ex
version of this function! Did you not even look at this function in the documentation? theEx
version of this function allows you to define security attributes to the folder that you create. That is the third parameter while using theEx
version and that is the only difference betweenSHCreateDirectory()
andSHCreateDirectoryEx()
. If you do not want to define security attributes, then do not use theEx
version.
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா
-
Good one !
Prasad Notifier using ATL | Operator new[],delete[][^]
Thanks!
Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா