Solved

Copy a file?

Posted on 1998-03-23
4
183 Views
Last Modified: 2010-04-10
How do I copy a autoexec.bat to the current directly (i mean the dir that has my app in it).   I would like this to be a VERY simple process, so please help me and explain everything!

thanks
0
Comment
Question by:stevenc317
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Slarti
ID: 1183767
Please tell us what OS and compiler you are using. (win95? dos?)
Would you like to write a program to do this, or just use a DOS command?
Also, if you want a full program, you will need to increase the amount of points.

0
 
LVL 11

Accepted Solution

by:
alexo earned 10 total points
ID: 1183768
In a program under windows95 and NT, you can use the CopyFile() function:
  CopyFile("c:\\autoexec.bat", ".\\autoexec.bat", FALSE);

If you want to do it in a batch file (mind the dot!):
   copy c:\autoexec.bat .

0
 
LVL 1

Author Comment

by:stevenc317
ID: 1183769
I am using Broland Builder v3.0 on Windows 95..  I just need a line or two of codes.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1183770
Use the CopyFile() function as I suggested above.

Documentation says:

The CopyFile function copies an existing file to a new 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
   );      
 
Parameters:
lpExistingFileName - Points to a null-terminated string that specifies the name of an existing file.
lpNewFileName - Points to a null-terminated string that specifies the name of the new file.
bFailIfExists - Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. 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.
 
Return Values:
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

726 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