You need to quickly store some data in a file, but the data will just be around for a little while.
Create a temporary file in the user's "official" temporary file area with the My.Computer. FileSystem.GetTempFileName() method:
Dim workFile As String = _ My.Computer.FileSystem. GetTempFileName( )
The filename returned represents a brand-new file created by the method that is zero bytes in size. When you are ready to use it, open it with one of the stream-based or file handle-based file-management methods, and make any additions or changes as needed. When you are finished, simply delete the file.
The temporary file is added to the user's default temporary file area and always has a .tmp extension. The filename is guaranteed to be unique and will not conflict with other temporary filenames stored in that same directory. The typical location for a logged-in Windows user is:
C:\Documents and Settings\<user>\Local Settings\Temp\
Recipe 12.16 discusses the editing of files using either stream-based or file handle-based methods.