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

x
?
Solved

Copy a file?

Posted on 1998-03-23
4
Medium Priority
?
185 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
[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
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 40 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

660 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