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

后端 未结 3 1483
鱼传尺愫
鱼传尺愫 2021-01-02 14:13

How to convert

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

into

String path = @\"C:\\A

3条回答
  •  旧巷少年郎
    2021-01-02 14:55

    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.

提交回复
热议问题