Exception: "URI formats are not supported."

I have an absolute local path pointing to the directory: "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj"

But when I try to drop it into the DirectoryInfo ctor, I get the exception "URI formats are not supported."

I googled and looked at SO, but I only see solutions with remote paths, not local ones. I would expect some kind of conversion method ...

+84
Sep 24 '12 at 7:35
source share
3 answers
 string uriPath = "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj"; string localPath = new Uri(uriPath).LocalPath; 
+176
Sep 24 '12 at 7:37
source share

try it

 ImagePath = "http://localhost/profilepics/abc.png"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream(); 
+1
Jul 27 '17 at 7:32
source share

I solved the same error using Path.Combine (MapPath ()) to get the physical file path instead of http: /// www.

0
May 24 '19 at 1:08
source share



All Articles