File.Delete : File « System.IO « C# / C Sharp by API






File.Delete

 


using System;
using System.IO;

class MainClass {
    static void Main() {
        string tempFile = Path.GetTempFileName();

        Console.WriteLine("Using " + tempFile);

        using (FileStream fs = new FileStream(tempFile, FileMode.Open)) {
            // (Write some data.)
        }

        // Now delete the file.
        File.Delete(tempFile);

    }
}

   
  








Related examples in the same category

1.File.CreateText(String fileName)
2.File.Exists(String fileName)
3.File.GetLastAccessTime
4.File.OpenRead
5.File.OpenText
6.File.OpenWrite
7.File.ReadAllLines(String fileName)
8.File.SetAccessControl
9.File.WriteAllLines(String fileName, String[] lines)