tags:

views:

337

answers:

1

The docs for Uri.LocalPath don't say what happens if you feed it a non local path like http://stackoverflow.com/. Does anyone know of a source that gives the official spec for how it handle this?

I'm wanting to know what kind of gotchas and corner cases it might have so I can't be sure I've got thing right by just trying things.

(alternately does anyone known of a robust way to check if a Uri is or is not local? Particularly, is it something I can access via the file-system)

+1  A: 

You're violating the pre-conditions by using it on a Uri that is not a "file name". Thus, as I see it, it can return whatever it pleases.

To see if a Uri is a filename, use Uri.IsFile

Matthew Flaschen
IsFile? What is it's not a file but a directory? Or is that just a not so clear name choice? (I won't say bad as I can't think of anything better: IsLocal? what about `\\mtserver\somthing`?)
BCS
Please read the documentation, not just the method name ("Gets a value indicating whether the specified Uri is a file URI."). file URI means it uses the file scheme. It has nothing to do with what kind of resource (file, directory, fifo, etc.) it is.
Matthew Flaschen
new Uri(@"\\mtserver\somthing").IsFile returns true, because the canonicalization (to file://mtserver/something) is done in the constructor.
Matthew Flaschen
If I completely read all the possibly related docs for every problem, that's all I'd ever do (and I wouldn't need SO). The only way anyone functions in life is by making (often, as in this case, somewhat invalid) assumption about what they can ignore.
BCS