Solved

CopyFile in VC++

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now