CSecurity
asked on
problem in copy a folder in Thread
Hello
i'm developing a application that in a thread, I wanna copy a folder (include all files and sub directories) to another and I found this:
https://www.experts-exchange.com/questions/20982249/Copy-Folders-in-C.html
as "Assisted Solution"s comment (AlexFM), first I use memset() to fill all my char array to NULL char ('\0') and then, when I use strcpy() the function works but after using strcpy(), I should use strcat() for append some text to my char array. when I use strcat(), the function does not work!!!! (so strange)
what should I do?
thank you very much
i'm developing a application that in a thread, I wanna copy a folder (include all files and sub directories) to another and I found this:
https://www.experts-exchange.com/questions/20982249/Copy-Folders-in-C.html
as "Assisted Solution"s comment (AlexFM), first I use memset() to fill all my char array to NULL char ('\0') and then, when I use strcpy() the function works but after using strcpy(), I should use strcat() for append some text to my char array. when I use strcat(), the function does not work!!!! (so strange)
what should I do?
thank you very much
char from[255], to[255];
memset(from,0,255);
memset(to,0,255);
strcpy(from,drive_letter); //drive_letter contain a folder path
strcpy(to,ini_path); //ini_path contain another folder path
strcat(to,"\\");
strcat(to,volume); //volume contain a name for folder-name
CopyFolder(from,to);
I don't see a reason to use memset()
What do you mean with strcat() doesn't work?
What do you mean with strcat() doesn't work?
Try to outut the final values to chek cwhether they are correct, e.g.
char from[255], to[255];
memset(from,0,255);
memset(to,0,255);
strcpy(from,drive_letter); //drive_letter contain a folder path
strcpy(to,ini_path); //ini_path contain another folder path
strcat(to,"\\");
strcat(to,volume); //volume contain a name for folder-name
MessageBoxA(NULL, from, "Copying from:", MB_OK);
MessageBoxA(NULL, to, "Copying to:", MB_OK);
CopyFolder(from,to);
Can you post the variable values for drive_letter, ini_path, and volume?
Did the directory separator ("\") get escaped within drive_letter and ini_path?
Did the directory separator ("\") get escaped within drive_letter and ini_path?
ASKER
ohh! I found out the problem! the function that copies a folder, works correctly when I give it a folder path but I wanna copy a drive! when i give the function this parameters, doesn't work:
CopyFolder("h:\\","f:\\tes t"); //can not copy drive
well, now i should get files in drive and get all folders and give all folder to CopyFolder() function. now, the problem is get files in a drive and get all foders to give all folders to CopyFolder function. how can I get files and folders?
thanks you very much
CopyFolder("h:\\","f:\\tes
well, now i should get files in drive and get all folders and give all folder to CopyFolder() function. now, the problem is get files in a drive and get all foders to give all folders to CopyFolder function. how can I get files and folders?
thanks you very much
What is the definition of CopyFolder?
ASKER
i found CopyFolder function here:
https://www.experts-exchange.com/questions/20982249/Copy-Folders-in-C.html
thanks
https://www.experts-exchange.com/questions/20982249/Copy-Folders-in-C.html
thanks
Yes, but have you checked whether the from/to paths are built correctly?
ASKER
yes, I'm sure because CopyFolder("h:\\","f:\\tes t"); doesnt work
What HRESULT do you get from 'SHFileOperation()'?
ASKER
hr = 1026
(SUCCEEDED(hr)) = 1 // I mean function returns 1
(SUCCEEDED(hr)) = 1 // I mean function returns 1
That's odd - this is not a valid HRESULT code...
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thank you very much
your link was useful ;)
CopyFolder("h:\\*.*","f:\\ test"); // *.* should be end of the source char array
thank you again
your link was useful ;)
CopyFolder("h:\\*.*","f:\\
thank you again
ASKER