C # file name/path handling method

Source: Internet
Author: User

  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/> ");         &nbsp     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    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.