Home > Net >  With a regular expression path.
With a regular expression path.

Time:01-20

As title, in the program has a code, is to obtain the file filename and suffix
The original with the following code
 string FileNameWithOutSuffix1=Regex. Match (Files [I], @ "(? <=\ \ [# \ w \ \ - \ \ '\ \ \?? \] * (?=\.) "). The ToString (); 

It's nice
Folder name, but recently a group of customers like to use., for example, 2020.10 (means folder name on behalf of their time)
But as a result, I the above code will fail, because in 2020 the name becomes
, please master action,

CodePudding user response:

System. IO. Path. GetFileName ()//access to the file name, including the suffix
System. IO. Path. GetFileNameWithoutExtension ()//access to the file name, not including the suffix
System. IO. Path. GetExtension ()//get the suffix

CodePudding user response:

System. IO. Path. GetExtension () this method
  •  Tags:  
  • C#
  • Related