System.IO.Path file name, path, extension processing

Source: Internet
Author: User

string FilePath [email protected] "e:/randy0528/Chinese catalog/justtest.rar";

Change the extension of the path string.
System.IO.Path.ChangeExtension (FilePath, "txt");
e:/randy0528/Chinese Catalogue/justtest.txt

Returns the directory information for the specified path string.
System.IO.Path.GetDirectoryName (FilePath);
e:/randy0528/Chinese Catalog

Returns the extension of the specified path string.
System.IO.Path.GetExtension (FilePath);
. rar

Returns the file name and extension of the specified path string.
System.IO.Path.GetFileName (FilePath);
Justtest.rar

Returns the file name of the specified path string that does not have a name extension.
System.IO.Path.GetFileNameWithoutExtension (FilePath);
Justtest

Gets the root directory information for the specified path.
System.IO.Path.GetPathRoot (FilePath);
e:/

Returns the random folder name or file name.
System.IO.Path.GetRandomFileName ();
Ct2h5b2h.sed

Creates a uniquely named 0-byte temporary file on the disk and returns the full path of the file.
System.IO.Path.GetTempFileName ();
C:/Documents and Settings/randy/local settings/temp/tmpad.tmp

Returns the path to the temporary folder for the current system.
System.IO.Path.GetTempPath ();
C:/Documents and Settings/randy/local settings/temp/

Determines whether the path includes a file name extension.
System.IO.Path.HasExtension (FilePath);
True

Gets a value that indicates whether the specified path string contains absolute path information or contains relative path information.
System.IO.Path.IsPathRooted (FilePath);
True

Reprint: http://blog.csdn.net/chanyinhelv/article/details/8432840

System.IO.Path file name, path, extension processing

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.