Remove file extension from a file name string

前端 未结 12 1681
一个人的身影
一个人的身影 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:53

    If you want to create full path without extension you can do something like this:

    Path.Combine( Path.GetDirectoryName(fullPath), Path.GetFileNameWithoutExtension(fullPath))
    

    but I'm looking for simpler way to do that. Does anyone have any idea?

提交回复
热议问题