08-23-2010 01:59 AM
does some body knows , how to copy a folder.
e.g. copy a:\a\*.* b:\
i did search in MSDN , and it looks the function copy folder only available in JS or VB, how can we do in C. ?
B.R
Gerry
Solved! Go to Solution.
08-23-2010 02:02 AM
08-23-2010 02:10 AM
sorry, i still have a question after i accept this soluction.
i saw once a file in target set attributes set as -readonly. the copyfile will return error . how can we overwrite. ?
08-23-2010 02:19 AM
...by further investigating the Utility library
here you will find the function SetFileAttrs ("", 1, 1, 1, 1); which you can use to set file attributes
08-23-2010 02:23 AM
is there any easy way. because it's need checking all files under the folder. just like normal copy. windows will popup a message box. if you select YES. then system will overwirte. how can we do by code ?
B.R
Gerry
08-23-2010 02:27 AM
I understand that you want to avoid the popup? You might then use the functions GetFirstFile ("", 1, 1, 0, 0, 0, 0, ); and GetNextFile where you can search for files with specified attributes
08-23-2010 02:41 AM
sorry, i did not write it clear.
in my application , i need keep updating local file from server. the idea is once netwrok available. copy the file from server to local. however, this is not only one file but a group under specified server directory. and most of files have been set attribute as read-only. so if you use copy file function. it will return error. since file with same name in local is read-only. however, if you use setattribtes function. you need check attribute of each files. and set them to none read-only first . . ..
so i just want to have a easy way . like i can set a overwrite flag in code. then whatever the attributes of files in local. just overwrite.
i am a lazy guy ! :
B.R
gerry
08-23-2010 03:01 AM
May be someone else knows better - I am not aware of such a 'lazy' flag
but actually it's not such an effort: you have to call GetFirstFile once, and then, in a loop, SetFileAttrs and GetNextFile, so it's just five lines of code...
08-23-2010 03:14 AM
i am now working with you suggestion. i searched MSDN and internet. and i did not find any better solutions in C code.
anyway, thanks very mcuh! let's waiting. peoplemay give a "lazy" solution. soon 🙂
08-23-2010 10:16 PM
maybe you can search for a WinAPI to invoke.