<div dir="ltr">Hello,<div><br></div><div>This is an unfortunate problem with the design of the Uri class.   They designed it so that it automatically turned things that looked like filenames into a file uri, instead of mandating that the "file:" scheme be present.</div>
<div><br></div><div>I have struggled to figure out a solution to the problem.</div><div><br></div><div>This means that when you do:</div><div><br></div><div> new Uri ("c:/foo");</div><div><br></div><div>It returns a Uri like this: "file://c:/foo" (or something like that, I do not have windows here).</div>
<div><br>To support this, we made new Uri ("/foo") become: file:///foo</div><div><br></div><div>This causes problems in countless places, in particular in places that distinguish between absolute Uris and relative uris.</div>
<div><br></div><div>There are a bunch of bugs filed around this particular issue, and fixing will just introduce a different set of bugs.</div><div><br></div><div>Miguel</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, May 14, 2014 at 10:56 AM, SilentBob <span dir="ltr"><<a href="mailto:cinnamondonkey@gmail.com" target="_blank">cinnamondonkey@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I am seeing an issue with XmlDocument  .Load() always throwing an exception.<br>
I have studied the code in the class library and noticed the following issue<br>
that can be narrowed down to Uri.cs.<br>
<br>
    Path.GetFullPath("dev0:/dir1/dir2") => "//dev0:/dir1/dir2"<br>
    Uri(Path.GetFullPath("dev0:/dir1/dir2")) => "file:///dev0:/dir1/dir2"<br>
<br>
Note '///' in XmlDocument seems to cause a problem with FileStream which<br>
throws and exception along the lines of can not find path<br>
"/dev0:/dir1/dir2".<br>
<br>
FileStream only seems happy seeing the following format: "dev0:/dir1/dir2"<br>
<br>
Looking at Uri.cs I can see:<br>
<br>
                private void ParseAsUnixAbsoluteFilePath (string uriString)<br>
                {<br>
                        isUnixFilePath = true;<br>
                        scheme = UriSchemeFile;<br>
                        port = -1;<br>
                        fragment = String.Empty;<br>
                        query = String.Empty;<br>
                        host = String.Empty;<br>
                        path = null;<br>
<br>
                        if (uriString.Length >= 2 && uriString [0] == '/' && uriString [1] ==<br>
'/') {<br>
                                uriString = uriString.TrimStart (new char [] {'/'});<br>
                                // Now we don't regard //foo/bar as "foo" host.<br>
                                /*<br>
                                int pos = uriString.IndexOf ('/');<br>
                                if (pos > 0) {<br>
                                        path = '/' + uriString.Substring (pos + 1);<br>
                                        host = uriString.Substring (0, pos);<br>
                                } else { // "///server"<br>
                                        host = uriString;<br>
                                        path = String.Empty;<br>
                                }<br>
                                */<br>
                                path = '/' + uriString;<br>
                        }<br>
                        if (path == null)<br>
                                path = uriString;<br>
                }<br>
<br>
<br>
Why is the code doing:<br>
<br>
    path = '/' + uriString;<br>
<br>
After stripping the leading '//' ?<br>
<br>
I'm assuming at some point the library simply tags on or removes "file://"<br>
as required.<br>
<br>
Regards,<br>
Shaun<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://mono.1490590.n4.nabble.com/Possible-issue-with-Uri-cs-tp4662793.html" target="_blank">http://mono.1490590.n4.nabble.com/Possible-issue-with-Uri-cs-tp4662793.html</a><br>
Sent from the Mono - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Mono-devel-list mailing list<br>
<a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
</blockquote></div><br></div>