Solved

Copy a file?

Posted on 1998-03-23
4
184 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

630 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