File.Delete 메서드를 사용하여 파일을 삭제합니다.
먼저 삭제할 파일의 경로를 설정합니다.
String myPath = @"C:\New\amit.txt";
이제 File.Delete 메서드를 사용하여 파일을 삭제합니다.
File.Delete(myPath);
다음은 완전한 코드입니다 -
예시
using System;
using System.IO;
public class Program {
public static void Main() {
String myPath = @"C:\New\amit.txt";
Console.WriteLine("Deleting File");
File.Delete(myPath);
}
} 출력
Deleting File