Solved

CopyFile in VC++

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to understand recursion 12 219
C++ mouse_event mouse look 7 70
c++ reading data from file into two dimensional array 3 96
FMX TCameraComponent Problem 2 54
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 clear a vector as well as how to detect empty vectors in C++.

863 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

26 Experts available now in Live!

Get 1:1 Help Now