Get a file name from a path

前端 未结 21 1587
面向向阳花
面向向阳花 2020-11-30 23:55

What is the simplest way to get the file name that from a path?

string filename = \"C:\\\\MyDirectory\\\\MyFile.bat\"

In this example, I s

21条回答
  •  一生所求
    2020-12-01 00:23

    I would do it by...

    Search backwards from the end of the string until you find the first backslash/forward slash.

    Then search backwards again from the end of the string until you find the first dot (.)

    You then have the start and end of the file name.

    Simples...

提交回复
热议问题