File.Copy 메서드를 사용하여 기존 파일의 복사본을 만듭니다.
복사하려는 파일의 경로를 추가합니다.
String myPath = @"D:\one.txt";
이제 위의 파일을 다음 파일에 복사하십시오 -
String myPath = @"D:\one.txt";
원본 파일과 대상 파일 모두에 File.Copy 메서드를 사용합니다.
File.Copy(myPath,newpath);
예시
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);
}
}