C:\Users\asus\AppData\Local\Temporary Projects\ConsoleApplication1\bin\Release\sfref.txt
如何拆分字符串以仅获取sfref.txt
您不需要正则表达式...
System.IO.Path.GetFilename(fullpath);
Use Path.GetFileName method:
var path = @"C:\Users\asus\AppData\Local\Temporary Projects\ConsoleApplication1\bin\Release\sfref.txt";
string name = Path.GetFileName(path); // sfref.txt
If you really need to do that with regular expressions (what I do not advice to do):
string name = Regex.Match(path, @"[^\\]*$").Value;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.