Solved

HELP!!!: Files Copying

Posted on 1998-10-22
2
176 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 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