C#可以通过Path.GetTempFileName获得一个临时文件,然后创建自己的临时文件
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); } }