This is working solution for PowerShell:
$uri = [Uri]"http://example.com/%2F"
# access the .PathAndQuery field to initialize the Uri object
$pathAndQuery = $uri.PathAndQuery
$flagsField = $uri.GetType().GetField("m_Flags", [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Instance)
$flagsValue = [UInt64]$flagsField.GetValue($uri)
# remove flags Flags.PathNotCanonical and Flags.QueryNotCanonical
$flagsValue = [UInt64]($flagsValue -band (-bnot 0x30));
$flagsField.SetValue($uri, $flagsValue)
Write-Host $uri.AbsoluteUri
Thanks to google-api-dotnet-client path :-) please note, that there is some difference with .net 2.0, my code is working for > .net 2.0 (for <= 2.0 versions, the type of flagsValue
object will be [Int32]
instead of [Uint64]
)