Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CopyFile 1

Status
Not open for further replies.

cnoob

Programmer
Oct 7, 2004
4
US
Can someone expain how to use the CopyFile? Also, what library\header is is located in? (#include)
 
if i'm trying to copy a file from a folder in the same directory, how would i do that? for examples, i'm trying to copy the file inside files\test.exe into the same directory as the file that was executed.
 
like how do you name a directory? like, lets say i wanna copy the file test.exe to C: what would i do?
 
//1. API
Code:
BOOL CopyFile(
  LPCTSTR lpExistingFileName, // name of an existing file
  LPCTSTR lpNewFileName,      // name of new file
  BOOL bFailIfExists          // operation if file exists
);
Code:
BOOL bCopy = ::CopyFile("C:\\temp\\test.exe", "C:\\temp2\\text.exe");
//2. C++.NET managed code:
Code:
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
String* srcpathfile = S"c:\\temp\\Test.exe";
String* dstfilepath = S"D:\\temp\\test.exe";

File::Copy(srcpathfile, dstfilepath); // overriding dst is not allowed 
File::Copy(srcpathfile, dstfilepath, true); // overriding dst is allowed
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top