Directives

12.1 Save all temporary files in the user’s Temp folder.

At times, it becomes necessary to create temporary files for all sorts of reasons. If a file is truly temporary (that is, it doesn’t need to be persisted for a future session), save the file in the user’s designated temporary folder.

In the past, it was often enough to assume that the user’s temporary folder was \Windows\Temp. This is no longer the case—especially with many users sharing computers under different profiles. You can determine a user’s temporary folder in a number of ways, including polling an environment variable and calling the API. However, the easiest (and best) way is to use a simple method in the .NET Framework. You might think that the method would be part ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.