Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HELP!!!: Files Copying

Posted on 1998-10-22
2
Medium Priority
?
180 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 100 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

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…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

704 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