What would be the correct way to create a fully URL-encoded file://
URI from a local path, i.e. where all special characters such as blanks etc are escaped?
Given the following input
C:\Data\Input Document.txt
I would like to get
file:///C:/Data/Input%20Document.txt
I've been using
Uri uri = new Uri(@"C:\Data\Input Document.txt", UriKind.RelativeOrAbsolute);
However, this results in an unescaped URI:
file:///C:/Data/Input Document.txt
it is already encoded
uri.AbsolutePath should give you "C:/Data/Input%20Document.txt"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With