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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EyooperAuthor Commented:
I don't know what happen but it started working.
0
basantCommented:
What should We can do now ?
0
EyooperAuthor Commented:
CopyFile works ok now, is there a simple way to copy directories?  
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

basantCommented:
Use Create Process for the command
xcopy /s source_dir target_dir


I used this method for my installation program
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.