This article mainly introduces C # file name/path processing method, when you write code processing files will be used to
Code is as follows: string filePath = @ "e:randy0528 Chinese directory Justtest.rar"; Response.Write ("File path:" +filepath); Response.Write (<br/>) Change the extension of the path string. <br/> "); Response.Write (System.IO.Path.ChangeExtension (FilePath, "txt"); Response.Write (<br/>) returns directory information for the specified path string ... <br/> "); Response.Write (System.IO.Path.GetDirectoryName (FilePath)); Response.Write ("<br/>" returns the extension of the specified path string. <br/> "); Response.Write (System.IO.Path.GetExtension (FilePath)); Response.Write ("<br/>" returns the filename and extension of the specified path string. <br/> "); Response.Write (System.IO.Path.GetFileName (FilePath)); Response.Write ("<br/>" returns the filename of a specified path string that does not have an extension. <br/> "); Response.Write (System.IO.Path.GetFileNameWithoutExtension (FilePath)) ; Response.Write ("<br/>" gets the root directory information for the specified path.) <br/> "); Response.Write (System.IO.Path.GetPathRoot (FilePath)); Response.Write ("<br/>" returns the random folder name or file name.) <br/> "); Response.Write (System.IO.Path.GetRandomFileName ()); Response.Write ("<br/>" creates a unique 0-byte temporary file on the disk and returns the full path to the file.) <br/> "); Response.Write (System.IO.Path.GetTempFileName ()); Response.Write ("<br/>" returns the path to the current system's temporary folder.) <br/> ");   Response.Write (System.IO.Path.GetTempPath ()); Response.Write ("<br/> determines whether the path includes the file name extension.) <br/> "); Response.Write (System.IO.Path.HasExtension (FilePath)); Response.Write ("<br/>" gets a value indicating whether the specified path string contains absolute path information or relative path information.) <br/> "); Response.Write (System.IO.Path.IsPathRooted (FilePath)); file path: e:randy0528 Chinese directory justtest.rar change the extension of the path string. e:randy0528 Chinese directory JustTest.txt Returns the directory information for the specified path string ... e:randy0528 Chinese Directory returns the extension of the specified path string.. rar returns the filename and extension of the specified path string. Justtest.rar returns the filename of the specified path string that does not have an extension. Justtest Gets the root directory information for the specified path. E: Returns a random folder name or file name. Ct2h5b2h.sed creates a uniquely named 0-byte temporary file on the disk and returns the full path to the file. C:documents and settingsrandylocal settingstemptmpad.tmp returns the path to the current system's temporary folder. C:documents and settingsrandylocal settingstemp determines whether the path includes a file name extension. True gets a value that indicates whether the specified path string contains absolute path information or relative path information. True