Remove Extra back slash “\” from string file path in c#

后端 未结 3 1844
滥情空心
滥情空心 2021-01-02 14:31

How to convert

\"String path = @\"C:\\Abc\\Omg\\Why\\Me\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";

into

String path = @\"C:\\A

3条回答
  •  执笔经年
    2021-01-02 14:52

    You can use path.TrimEnd('\\'). Have a look at the documentation for String.TrimEnd.

    If you want the trailing slash, you can add it back easily.

提交回复
热议问题