Solved

Copy a file?

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

785 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