Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CopyFile in VC++

Posted on 1998-11-26
4
Medium Priority
?
3,545 Views
Last Modified: 2008-03-10
Hi,
Could someone tell please tell me if there is any way of using CopyFile (or is there a similar funciton)  that I can use to copy files with "*.ini" (*.*, etc)?
i.e.
copyfile("c:\\temp\\*.ini","d:\\dest");

or, will I have to write a function to do this?

Thanks.
0
Comment
Question by:fredop
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 270 total points
ID: 1178693
You will need to use FindFirstFile() and FindNextFile() with CopyFile in order to achieve what you want.
A simple wrapper function in your code, really easy to code.
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1178694
Written quickly I'd do something like this:

HANDLE          hFile;
WIN32_FILE_DATA data;
BOOL            bContinue = TRUE;

hFile = FindFirstFile("*.ini", &data);
if( hFile != INVALID_HANDLE_VALUE )
  bContinue = FALSE;
while(bContinue) {
  CopyFile(data.cFileName, "c:\temp\");
  bContinue = FindNextFile(hFile, &data);
}
0
 

Author Comment

by:fredop
ID: 1178695
Thanks,
That's what I'll  do.
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1178696
Written quickly I'd do something like this:

HANDLE          hFile;
WIN32_FILE_DATA data;
BOOL            bContinue = TRUE;

hFile = FindFirstFile("*.ini", &data);
if( hFile != INVALID_HANDLE_VALUE )
  bContinue = FALSE;
while(bContinue) {
  CopyFile(data.cFileName, "c:\temp\");
  bContinue = FindNextFile(hFile, &data);
}
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question