Replace the last occurrence of a word in a string - C#

前端 未结 7 1913
星月不相逢
星月不相逢 2020-12-09 14:07

I have a problem where I need to replace the last occurrence of a word in a string.

Situation: I am given a string which is in this format:

相关标签:
7条回答
  • 2020-12-09 15:13

    You can use a Path class from System.IO namepace:

    string filePath = "F:/jan11/MFrame/Templates/feb11";
    
    Console.WriteLine(System.IO.Path.GetDirectoryName(filePath));
    
    0 讨论(0)
提交回复
热议问题