Wrox Programmer Forums
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2003, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying a File, How?

Copying a file should be a fairly simple task. As an example, I have a file Template.mdb and I want to copy and rename the file to Production.mdb. I have found the CFile class giving the ability to Rename and Remove a file but I have not seen any method to copy a file.

I know of several ways to do this in VB using Name file1 As file2 or using the File System Objects.

Any help would be greatly appreciated.

Larry Asher
__________________
Larry Asher
 
Old September 12th, 2003, 01:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Try CopyFile.
 
Old September 12th, 2003, 07:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

Larry Asher
 
Old September 16th, 2003, 03:37 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the api function copyfile to finish it.

 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
);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in copying some row and coloums to a file RAMBO29 Excel VBA 2 March 15th, 2007 03:05 AM
Copying and connecting to a file metal2000man BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 May 31st, 2006 12:35 PM
image file copying! heerajee Pro PHP 2 March 22nd, 2006 06:19 AM
copying file from one machine to other CsharpHelp C# 0 October 23rd, 2005 05:22 AM
copying the file from one machine to other CsharpHelp C# 0 October 23rd, 2005 05:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.