Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#에서 파일 삭제

<시간/>

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