I have C# code that is trying to get the LocalPath for a executing assembly using the following line of code:
Uri uri = new Uri(Assembly.GetExecut
I assume The URI functions are stripping away everything after the sharp # because it thinks its an anchor.
URI are designed for identifying resources on the internet, so your # character would be an illegal character in the middle of any URI.
Take even this question for example, the Title is
System.Uri fails to give correct AbsolutePath and LocalPath if the Path contains “#”
but the end of the URL has the "#" stripped away
system-uri-fails-to-give-correct-absolutepath-and-localpath-if-the-path-contains
Why do you need to convert it into a URI anyway. The only difference between these 3 console.writelines is the fact that the first two are prefixed with File:///
Console.WriteLine(Assembly.GetExecutingAssembly().CodeBase); // 1
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
Console.WriteLine(uri); // 2
Console.WriteLine(uri.LocalPath); // 3