The Path class. This class is specifically used to manipulate the path.

Source: Internet
Author: User

<1>

Using system;using system.collections.generic;using system.linq;using system.text;using System.IO;namespace path Path {/    <summary>//path This class is specifically used to manipulate the path. </summary> class Program {static void Main (string[] args) {string str = @ "H:\ Deer Ding            Kee \ Eighth. rmvb "; Now we're going to get the name "eighth episode. Rmvb".            We can get it that way. string fileName = str. Substring (str.            LastIndexOf ("\ \") +1); Console.WriteLine (FileName); Output: Eighth. RMVB//-------------------------------------------------------///In addition to the above method, we have a better way.            -------get the file name; string fileName2 = Path.getfilename (str); Console.WriteLine (fileName2);            Output: Eighth episode. RMVB//Get file name without extension string fileName3 = Path.getfilenamewithoutextension (str); Console.WriteLine (FileName3);            Output: Eighth episode//Get file extension string expansionname = Path.getextension (str); Console.WriteLine (Expansionname); Output:. RMVB//Get a custom path string for absoluteTo path string fullPath = Path.GetFullPath (str); Console.WriteLine (FullPath);//output: H:\ ding lu \ Eighth. RMVB//Connect "two strings" as path string strpath = Path.Combine (@ "D:\            A\ "," b.txt "); Console.WriteLine (strpath);        Output: D:\a\b.txt console.readkey (); }    }}


The Path class. This class is specifically used to manipulate the path.

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.