Remove file extension from a file name string

前端 未结 12 1724
一个人的身影
一个人的身影 2020-11-27 14:18

If I have a string saying \"abc.txt\", is there a quick way to get a substring that is just \"abc\"?

I can\'t do an fileName.IndexOf(

12条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 14:48

    This implementation should work.

    string file = "abc.txt";
    string fileNoExtension = file.Replace(".txt", "");
    

提交回复
热议问题