1. Only one temporary file can be created in the temporary file and the complete path of the file is returned. // Only one temporary file can be created in the temporary file and the complete path of the file is returned:
// C: \ Documents ents and Settings \ yourname \ Local Settings \ temp \ tmp3e6. tmp
System. Io. Path. gettempfilename ();
2. Return the complete path of the file with the unique name in the Temporary Folder Based on the file name. /// <Summary>
/// Return the complete path of the file with the unique name in the Temporary Folder Based on the file name.
/// Format: company document (1).doc,company document (2).doc
/// </Summary>
Public Static String Gettemppathfilename ( String Filename)
{
// Temporary system folder
String Temppath = Path. gettemppath ();
// File completion path
Filename = Temppath + Path. getfilename (filename );
// File Name
String Filenamewithoutext =
Path. getfilenamewithoutextension (filename );
// Extension
String Fileext = Path. getextension (filename );
Int I = 0 ;
While (File. exists (filename ))
{
// Generate a file name like this: company document (1).doc,company document (2).doc
Filename = Temppath + Filenamewithoutext +
String . Format ( " ({0 }) " , ++ I) + Fileext;
}
Return Filename;
}
3. Return the path of the temporary folder of the system.//Return the path of the temporary folder of the system:
//C: \ Documents ents and Settings \ yourname \ Local Settings \ temp \
System. Io. Path. gettemppath ();
4. Return a random file name.//Returns a random file name, 41ceduv1. UWV.
System. Io. Path. getrandomfilename ();