Solved

HELP!!!: Files Copying

Posted on 1998-10-22
2
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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