URI Possible Bug?

  • Thread starter mark_overstreet
  • Start date
M

mark_overstreet

The following code appears to be a bug. Can anyone confirm?


Uri newURI = new
Uri("file:///C:/Projects/Labor/Helpdesk/Source/C#/Labor.Helpdesk.Website.Solution/Labor.Helpdesk.Website/bin/Labor.Helpdesk.DataLayer.DLL");

Console.Writeline(newURI.LocalPath);

Output:

C:\Projects\Labor\Helpdesk\Source\C

This does not return the entire path as expected or am I missing
something?

Thanks
Mark
 
D

Dustin Campbell

The following code appears to be a bug. Can anyone confirm?
Uri newURI = new
Uri("file:///C:/Projects/Labor/Helpdesk/Source/C#/Labor.Helpdesk.Websi
te.Solution/Labor.Helpdesk.Website/bin/Labor.Helpdesk.DataLayer.DLL");
Console.Writeline(newURI.LocalPath);

Output:

C:\Projects\Labor\Helpdesk\Source\C

This does not return the entire path as expected or am I missing
something?

pound symbols (#) have special meaning in URIs. They are used to delmit a
fragment identifier in a URI reference. See RFC 2396 at http://tools.ietf.org/html/rfc2396
for details. Escaping the # character works fine:

Uri newURI = new
Uri("file:///C:/Projects/Labor/Helpdesk/Source/C%23/Labor.Helpdesk.Website.Solution/Labor.Helpdesk.Website/bin/Labor.Helpdesk.DataLayer.DLL");

Console.Writeline(newURI.LocalPath);


Best Regards,
Dustin Campbell
Developer Express Inc.
 
M

mark_overstreet

Thanks. One more thing. The path I am getting is not hardcoded but
from a built in class as follows and is not escaped. How can I escape
it?

System.Reflection.Assembly.GetExecutingAssembly().Location
 
B

Ben Voigt

Thanks. One more thing. The path I am getting is not hardcoded but
from a built in class as follows and is not escaped. How can I escape
it?

Uri.EscapeUriString, but better would be to use UriBuilder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top