GetTempFileName The GetTempFileName function creates a name for a temporary file. The filename is the concatenation of specified path and prefix strings, a hexadecimal string formed from a specified integer, and the .TMP extension.The specified integer can be nonzero, in which case, the function creates the filename but does not create the file. If you specify zero for the integer, the function creates a unique filename and creates the file in the specified directory.UINT GetTempFileName( LPCTSTR lpPathName, // pointer to directory name for temporary // file LPCTSTR lpPrefixString, // pointer to filename prefix UINT uUnique, // number used to create temporary filename LPTSTR lpTempFileName // pointer to buffer that receives the new // filename );
The GetTempFileName function creates a name for a temporary file. The filename is the concatenation of specified path and prefix strings, a hexadecimal string formed from a specified integer, and the .TMP extension.The specified integer can be nonzero, in which case, the function creates the filename but does not create the file. If you specify zero for the integer, the function creates a unique filename and creates the file in the specified directory.UINT GetTempFileName(
LPCTSTR lpPathName, // pointer to directory name for temporary
// file
LPCTSTR lpPrefixString, // pointer to filename prefix
UINT uUnique, // number used to create temporary filename
LPTSTR lpTempFileName
// pointer to buffer that receives the new
// filename
);
TempFileCollection tfc = new TempFileCollection(filepath,false);
string filename = tfc.AddExtension("**",false);//文件类型名。
返回的文件名即唯一的文件