Create a temp file and delete it : Temp File : File Directory Stream C# Examples


C# Examples » File Directory Stream » Temp File »

 

Create a temp file and delete it









    
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);

        }
}
    
   
  
   



Output

Using C:\Documents and Settings\Joe\Local Settings\Temp\tmp1AE4.tmp


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» Temp File