Solved

CopyFile in VC++

Posted on 1998-11-26
4
3,529 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 90 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

786 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