Copying data

How do i copy a folder of .txt documents and subfolders to another destination

if you want more points ill will add them upon request

send no links code only
the_hood00Asked:
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.

AaronReamsCommented:
You could always do it the easy way if you don't mind calling an external dos app.

ShellExecute(NULL,"open","xcopy","/S /C C:\\temp\\copy\\copy1\\*.txt C:\\temp\\copy\\copy2\\","",SW_SHOWMINIMIZED);


Hope this helps,
Aaron
0
jkrCommented:
I'd

use 'SHFileOperation()' instead, it comes with its own progress:

void CopyTree ( char* pszDst, char* pszSrc) {

SHFILEOPSTRUCT sfo;

ZeroMemory ( &sfo, sizeof ( sfo));

sfo.pFrom = pszSrc;
sfo.fTo = pszDst;
sfo.wFunc = FO_COPY;
sfo.fFlags = FOF_SIMPLEPROGRESS;
sfo.lpszProgressTitle = "Copying your files...";

SHFileOperation ( &sfo);
}

You can also turn off the progress if you want to.
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
AaronReamsCommented:
kewl, thanks for pointing out that function jkr.  I knew my way was kind of a hack but i threw it out there as a suggestion.

I'm curious about SHFileOperation.  I'll have to try it out tomorrow.  One question:  would he be able to only copy the txt files in the tree structure by passing in the pszSrc directory as <dir>\*.txt?

Cheers mate! -Aaron

0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

the_hood00Author Commented:
         

           ok i think ill try the SHFileOperation but could you tell me what the variables are in your code example.
0
the_hood00Author Commented:
how do i add that code to a button
0
jkrCommented:
The variables are documented in the help files or at MSDN: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/structures/browseinfo.asp ("BROWSEINFO")

>> how do i add that code to a button

I assume that you mean execute that when a button is clicked? Call the function from your button handler.

BTW, don't know from the top of my head if wildcards will work.

0
the_hood00Author Commented:
i get this error
error C2039: 'fTo' : is not a member of '_SHFILEOPSTRUCTA'
        c:\program files\microsoft visual studio\vc98\include\shellapi.h(255) : see declaration of '_SHFILEOPSTRUCTA'

how do i fix this
0
the_hood00Author Commented:
nevermind i fixed it
0
the_hood00Author Commented:
when i try coping an .exe file i get a can not read from source file or disk even though the .exe exists and the path of it is correct
0
the_hood00Author Commented:
this is my code




CString CSclientextrac=("C:\\Client Version");
::CreateDirectory(CSclientextrac, NULL);
CSclientextrac=("C:\\Client Version\\dat");
::CreateDirectory(CSclientextrac, NULL);

CString CSfrom("C:\\Program Files\\Geoffism Studios\\set\\View.exe");
CString CSto("C:\\Client Version\\View.exe");



SHFILEOPSTRUCT sfo;

ZeroMemory ( &sfo, sizeof ( sfo));

sfo.pFrom = CSfrom;
sfo.pTo = CSto;
sfo.wFunc = FO_COPY;
sfo.fFlags = FOF_SIMPLEPROGRESS;
sfo.lpszProgressTitle = "Copying your files...";

SHFileOperation ( &sfo);
0
jkrCommented:
>>CString CSfrom("C:\\Program Files\\Geoffism Studios\\set\\View.exe");

This path contains spaces, yo you have to enclose that one in double quotes:

CString CSfrom("\"C:\\Program Files\\Geoffism Studios\\set\\View.exe\"");

The above should work.
0
the_hood00Author Commented:
and i want to change CSto so that it will copy the file to the desktop of the person running the program how do i do that
0
the_hood00Author Commented:
is there a diffrent way to delete a folder of files and subdirectories other then with SHFileOperation() and the string of the path to the folder has variables in it
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
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.