I need to pass local path to HttpWebRequest in c#. i have test.xml in my c drive and i need get that xml file in HttpWebRequest. but it throws exception in
HttpWebRequest rqst = (HttpWebRequest)HttpWebRequest.Create(Uri.EscapeUriString(urlServ))
line "Invalid URI: The Authority/Host could not be parsed."
my coding->
string urlServ = "file:\\c:\\test.xml";
try
{
HttpWebRequest rqst = (HttpWebRequest)HttpWebRequest.Create(Uri.EscapeUriString(urlServ));
rqst.KeepAlive = false;
}
catch{}
I believe a file: URI is supposed to be created with forward-slashes, not back slashes. So, use this:
string urlServ = "file:///c:/test.xml";
I noticed when I typed it into my browser with backslashes, FF converted it to forward slashes for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With