Thursday, July 27, 2006

Temporary File Name

The Path.GetTempFileName() It's an easy way to reserve a temporary file name without having to reinvent the wheel, Pretty neat.

Once GetTempFileName() is called a temporary zero-length file is created for you, therefore guaranteeing it's availability.
The only gripe I have is that I cannot change the file extension without doing more I/O work on the file. It would have been nice if there was an overload to change the extension. For Instance, generating temporary HTML files etc... Files generated are currently with the *.tmp extension.

1 comment:

Mads Kristensen said...

This is very exciting. I have never heard about this method before, and it's very cool. It reminds me of using Isolated Storage for this purpose, but this is much cooler.