Create a temp file and delete it in CSharp
Description
The following code shows how to create a temp file and delete it.
Example
//from w w w . j a va 2s . c om
using System;
using System.IO;
static class MainClass
{
static void Main()
{
string tempFile = Path.GetTempFileName();
Console.WriteLine("Using " + tempFile);
using (FileStream fs = new FileStream(tempFile, FileMode.Open))
{
// (Write some data.)
}
File.Delete(tempFile);
}
}
The code above generates the following result.