Article ID: 210602 - Last Review: October 11, 2006 - Revision: 2.2 ACC2000: Sample Function to Generate a Random Temporary File NameThis article was previously published under Q210602 Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
This article shows you how to create a sample function that generates a
random file name that can be used for a temporary file. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. MORE INFORMATION
Sometimes, an application has to create a file that it uses temporarily and
then deletes. The names of temporary files are important and you do not want your application to inadvertently overwrite an existing file.
In such cases, you can create and use the user-defined function called MakeTempFileName(). This function accepts a file extension and returns a string representing a non-existent, random file name with the file extension that you specify. The file name includes a path to your Windows Temp folder (directory) so that the temporary file is placed in the same folder that Windows uses to write its temporary files. This is handy for those who perform periodic maintenance on their hard disks and delete any leftover temporary files in the Windows Temp folder. To create the sample function MakeTempFileName(), follow these steps:
| Article Translations
|
Back to the top
