C # get filenames, directories, suffixes, no suffix filenames, extensions, root directories, and so on

Source: Internet
Author: User

[CSharp] View plain copyclassProgram {Static voidMain (string[] args) {                //gets the directory of the currently running program            stringFiledir =environment.currentdirectory; Console.WriteLine ("Current Program directory:"+Filedir); //a file directory            stringFilePath ="C:\\jiyf\\benxh\\benxhcms.xml"; Console.WriteLine ("directory for this file:"+FilePath); stringstr ="get the full path of the file:"+ Path.GetFullPath (FilePath);//-->c:\jiyf\benxh\benxhcms.xmlConsole.WriteLine (str); STR="get the directory where the files are located:"+ Path.getdirectoryname (FilePath);//-->c:\jiyf\benxhConsole.WriteLine (str); STR="gets the name of the file that contains the suffix:"+ Path.getfilename (FilePath);//-->benxhcms.xmlConsole.WriteLine (str); STR="the name of the get file does not have a suffix:"+ path.getfilenamewithoutextension (FilePath);//-->benxhcmsConsole.WriteLine (str); STR="gets the suffix extension name of the path:"+ path.getextension (FilePath);//-->.xmlConsole.WriteLine (str); STR="get the root directory of the path:"+ Path.getpathroot (FilePath);//-->c:\Console.WriteLine (str);            Console.readkey (); }      }  

C # get filenames, directories, suffixes, no suffix filenames, extensions, root directories, and so on

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.