Path functions for URL

后端 未结 4 1454
盖世英雄少女心
盖世英雄少女心 2021-01-18 13:13

I want to use functions of Path class (GetDirectoryName, GetFileName, Combine,etc.) with paths in URL format with slash (/).

E

4条回答
  •  太阳男子
    2021-01-18 13:28

    I'm afraid GetDirectoryName, GetFileName, Combine,etc. use Path.DirectorySeparatorChar in the definition and you want Path.AltDirectorySeparatorChar.

    And since Path is a sealed class, I think the only way to go about is string replacement.You can replace Path.DirectorySeparatorChar('\') with Path.AltDirectorySeparatorChar('/') and Path.VolumeSeparatorChar(':') with ":/"

提交回复
热议问题