

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to make a copy of an existing file
Use File.Copy method to make copy of an existing file.
Add the path of the file you want to copy.
String myPath = @"D:\one.txt";
Now copy the above file to the following file −
String myPath = @"D:\one.txt";
Use the File.Copy method with both the source and destination file.
File.Copy(myPath,newpath);
Example
using System; using System.IO; public class Program { public static void Main() { String myPath = @"D:\one.txt"; // the file will get copied here String newpath = @"D:\two.txt"; // copying file File.Copy(myPath,newpath); } }
- Related Questions & Answers
- Java Program to Append Text to an Existing File
- How to create a duplicate file of an existing file using Python?
- Creating a copy of an existing Attribute view in SAP HANA
- Write a C program to find total number of lines in an existing file
- C program to copy the contents of one file to another file?
- Program to make a copy of a n-ary tree in Python
- How to make an existing field Unique in MySQL?
- Check whether the given file is an existing file in Java
- How to add a JSON string to an existing JSON file in Java?
- How to add/append content to an existing file using Java?
- Program to make a histogram of an array in C++
- Program to make file names unique using Python
- Append to an existing file stored in SD Card connected to Arduino
- Java Program to write an array of strings to a file
- fopen() for an existing file in write mode in C
Advertisements