LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

copyfolder

Solved!
Go to solution

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

0 Kudos
Message 1 of 21
(5,202 Views)
Solution
Accepted by topic author Gerryli

you could use the function CopyFile ("", ""); from the Utility library

Message 2 of 21
(5,203 Views)

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. ?

0 Kudos
Message 3 of 21
(5,198 Views)

...by further investigating the Utility library Smiley Happy

 

here you will find the function SetFileAttrs ("", 1, 1, 1, 1); which you can use to set file attributes

0 Kudos
Message 4 of 21
(5,197 Views)

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

0 Kudos
Message 5 of 21
(5,196 Views)

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

0 Kudos
Message 6 of 21
(5,200 Views)

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 ! :Smiley Very Happy

 

B.R

gerry

0 Kudos
Message 7 of 21
(5,187 Views)

May be someone else knows better - I am not aware of such a 'lazy' flag Smiley Wink

 

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...

0 Kudos
Message 8 of 21
(5,183 Views)

i am now working with you suggestion.  i searched MSDN and internet. and i did not find any better solutions in  C code. Smiley Sad

 

anyway, thanks very mcuh!    let's waiting.  peoplemay  give a "lazy" solution. soon 🙂

0 Kudos
Message 9 of 21
(5,179 Views)

maybe you can search for a WinAPI to invoke.

0 Kudos
Message 10 of 21
(5,149 Views)