Solved

HELP!!!: Files Copying

Posted on 1998-10-22
2
173 Views
Last Modified: 2013-11-20
Q1)
I need to copy some graphic files from a directory to another directory.... May I know how to do it???

Q2)
How to create a directory in MFC???

Can pls show a simple sample codes to demo???

Thanks in advance!!! :-)
0
Comment
Question by:samyee
2 Comments
 

Accepted Solution

by:
rakeshkalra earned 50 total points
ID: 1323732
You will have to use some windows APIs for both purposes.

ans 1:
Use the CopyFile function for copying the file:

BOOL CopyFile( LPCTSTR lpExistingFileName,
                    // pointer to name of an existing file
               LPCTSTR lpNewFileName,
                    // pointer to filename to copy to
               BOOL bFailIfExists
                   // flag for operation if file exists
              );

bFailIfExists: If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.

example:

if(!CopyFile("c:\\test.bmp", "c:\\windows\\test.bmp", FALSE ))
{
  // handle error
}
it copies test.bmp from c:\ to c:\windows and overwrites the file if present.

ans 2:
Use CreateDirectory :

if(!CreateDirectory( "c:\\windows\\mydirectory", NULL))
{
  // handle error
}
 
This creates a directory called 'mydirectory' in c:\windows
Imp: See that 'c:\windows' should exist, otherwise this call will fail.

0
 

Author Comment

by:samyee
ID: 1323733
Thanks...
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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

10 Experts available now in Live!

Get 1:1 Help Now