1. can only create a temporary file in a temporary file and returns the full path of the file
// can only create a temporary file in a temporary file and returns the full path to the file: // C: \ Documents and Settings \ YourName \ Local Settings \ the Temp \ tmp3E6.tmp System.IO.Path.GetTempFileName ();
2. The full path to the file name returned in the temporary folder uniquely named file
/// <Summary> /// The return to the full path name of the file in the temporary folder uniquely named file /// form: Corporation document (1) .doc, corporate documents (2) .doc /// </ Summary> publicstaticstringGetTempPathFileName (stringfileName) { // the system temporary folder stringtempPath = Path.GetTempPath (); // complete file path fileName = temppath + Path.GetFileName (fileName); // file name stringfileNameWithoutExt = Path.GetFileNameWithoutExtension (fileName) ; // extension stringfileExt = Path.GetExtension (fileName); Inti = 0 ; the while (the File.Exists (fileName)) { // generates a file name like this: corporate documents (1) .doc, corporate documents (2) .doc fileName = temppath fileNameWithoutExt + + String .Format ( " ({0}) " , ++ I) + FileExt; } returnfileName; }
3. Return to the path system temporary folder
// path back to the system temporary folder: // C: \ Documents and Settings \ YourName \ Local Settings \ the Temp \ System.IO.Path.GetTempPath ();
4. returns a random file name
// returns a random file name: 41ceduv1.uwv System.IO.Path.GetRandomFileName ();