Is t开发者_如何学编程here any way to have temp file inside a temp directory in c# solution and write the bytes into that and after finishing our process delete it without showing that file to users ?
consider using
string tempFile = Path.GetTempFileName();
//Use the file
File.Delete(tempFile);
using System.IO;
class Logger
{
static void Main()
{
// Create (and open) a new temporary file
var filename = Path.GetTempFileName();
var file = File.Open(filename, FileMode.Append);
// Write bytes to it during the programs lifetime...
file.Write(new byte[] { 1, 2, 3 }, 0, 3);
// Just before closing your program, close and delete it
file.Close();
File.Delete(filename);
}
}
精彩评论