I think I’m missing something obvious….
I’ve been reading code in a new project and have encountered code equivalent to the following:
var filePath = @"C:\temp\tmp1234.tmp"; // Generally obtained from System.IO.* calls
var uri = new Uri("file://" + filePath);
I thought that would be equivalent to:
var filePath = @"C:\temp\tmp1234.tmp";
var uri = new Uri(filePath);
(assuming the Uri class can parse the file path, deduce the scheme and do whatever escaping needs doing).
Since the code seems to work and this being done so frequently and so consistently I’m assuming the original developer had a good reason for using the "file://" + filePath idiom. Could someone clue me in about what that reason might be?
Thanks!
They both generate completely identical
Uriobjects, except (obviously) for theOriginalString.You can see this in LINQPad:
I would guess that the original developer wasn’t aware of that.