Solved

Copy a file?

Posted on 1998-03-23
4
180 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now