C# program to copy existing files

WBOY
Release: 2023-09-08 18:21:16
forward
1927 people have browsed it

C# 程序复制现有文件

Copy an existing file using the File.Copy method.

Add the path of the file to be copied.

String myPath = @"D:\one.txt";
Copy after login
Copy after login

Now copy the above file into the following file −

String myPath = @"D:\one.txt";
Copy after login
Copy after login

Use the File.Copy method, specifying both the source file and the destination file.

File.Copy(myPath,newpath);
Copy after login

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);
   }
}
Copy after login

The above is the detailed content of C# program to copy existing files. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!