
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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 Articles
- Golang program to append a string in an existing file
- Java Program to Append Text to an Existing File
- Copy a directory to an existing directory Linux?
- How to create a duplicate file of an existing file using Python?
- Write a C program to find total number of lines in an existing file
- Creating a copy of an existing Attribute view in SAP HANA
- C program to copy the contents of one file to another file?
- Golang program to copy one file into another file
- Program to make a copy of a n-ary tree in Python
- Golang program to make a file read-only
- How to make an existing field Unique in MySQL?
- How to add a JSON string to an existing JSON file in Java?
- Check whether the given file is an existing file in Java
- How to add/append content to an existing file using Java?
- Append to an existing file stored in SD Card connected to Arduino

Advertisements