【问题标题】:Convert network Path containing a "@" to URI将包含“@”的网络路径转换为 ​​URI
【发布时间】:2020-12-15 00:33:20
【问题描述】:

我想将网络路径(目录“\www.dummy.com@ABC\test”)转换为 URI:

var uri = new Uri(path, UriKind.RelativeOrAbsolute);

发生 URIFormatException

我该如何解决这个问题?

【问题讨论】:

标签: c# .net uri


【解决方案1】:

我认为您需要将 UriKind 枚举更改为 Relative 值。 这段代码 sn-p 工作正常:

const string path = @"\www.dummy.com@ABC\test";
var uri = new Uri(path, UriKind.Relative);
Console.Write(uri);

// Output:
// \www.dummy.com@ABC\test

【讨论】:

    猜你喜欢
    • 2017-08-09
    • 2022-12-01
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    相关资源
    最近更新 更多