
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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); } }
Advertisements