Temporary file
In this chapter you will learn:
Create temporary file
The following code creates a temporary file and delete it.
using System;// j a v a2s.co m
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.
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » File, Path