The problem is with the creation of the URI, it seems there is some bug with the URI class.
The URI generated by the following are different,
var filePath = @"c:\MyFile.Html#tips";
var uri = new Uri(filePath);
var uri2 = new Uri("file://" + filePath);
Fragment part of the uri
is empty, but uri2
has correct fragment part as "#tips".
The same kind of problem is with the query even after creating URI as uri2
, the reported bug for query
string can be found here, Why doesn't System.Uri recognize query parameter for local file path? and Uri class does not parse filesystem URL with query string