Solved

HELP!!!: Files Copying

Posted on 1998-10-22
2
172 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
Comment Utility
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
Comment Utility
Thanks...
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 63
Strange date stored 22 99
Question regarding Copy/Paste 16 86
iSeries DB2 Query 2 83
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

14 Experts available now in Live!

Get 1:1 Help Now