[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