CopyFile access denied

I'm writting a File Manager program in MASM assembler.
Everthing is looking fairly good, I have a tree view and two
list views and a toolbar with the volume icons. I can change
the display to a tree view and one list view or just two list views.

The problem is I would like to copy files or folders from one
list view to the other. I can do it by using readfile and writefile,
but I would like to use the CopyFile function. When I try to use
it I get an access denied error. I've changed the source file to
read only access, but it still didn't work.

Do I need to do a CreateFile?

My command is:

INVOKE     CopyFile, addr InFile, addr OutFile, FALSE

The source and destination paths look ok.

Thanks;
EyooperAsked:
Who is Participating?
 
basantConnect With a Mentor Commented:
Use Create Process for the command
xcopy /s source_dir target_dir


I used this method for my installation program
0
 
EyooperAuthor Commented:
I don't know what happen but it started working.
0
 
basantCommented:
What should We can do now ?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
EyooperAuthor Commented:
CopyFile works ok now, is there a simple way to copy directories?  
0
 
EyooperAuthor Commented:
Thanks the xcopy works ok. But what can I do about the hidden
or system files or hidden directories within the directory that is
being copied? Is there a way to intercept the file or directory
that is being copied so I can change the attributes?

Thanks;
0
 
EyooperAuthor Commented:
I have decided to use the SHFileOperation function instead of
copyfile and xcopy for my copy, move, rename, and delete
operations. I have only tried the copy portion of the SHFileOperation and everthing looks ok it copied hidden and system files, hidden subdirectories and all of the other good stuff.

But when I copy a folder with several files within the folder and the destination path has the same folder and files I get a Confirm Folder Replace msg box, so far so good, then I get a
Confirm File Replace msg box with a YES and  YES TO ALL
buttons. When I press the YES button I would think that the
Confirm File Replace msg box would appear for the next duplicated file, but it dosn't it just replaces the rest of the files. It acts like I pressed the YES TO ALL button. I'm I missing something?

Thanks;
0
 
basantCommented:
/H option of xcopy copies hidden and
system file too.

>Is there a way to intercept the file or directory
that is being copied so I can change the attributes?

Options :
/R           Overwrites read-only files.
0
 
EyooperAuthor Commented:
I found the problem with the SHFileOperation function (Confirm File Replace msg box).

I tried the xcopy with the /H, /R options and the it worked as
designed. Where can I find documentation for the /H and /R
options?
OK now I have a Problem both the SHFileOperation function
and the xcopy do what I need to have done. If you were me
which one would you use?
I will close this question after your answer.

Thanks again;
0
 
basantCommented:
Use xcopy /?

I hope you knew it.
0
 
EyooperAuthor Commented:
You can close this question.
0
All Courses

From novice to tech pro — start learning today.