Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: "URI formats are not supported"

Tags:

c#

.net

.net-4.0

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

But when I try to throw it into DirectoryInfo's ctor I get the "URI formats are not supported" exception.

I googled and looked on SO, but I only see solutions with remote paths, not local ones. I'd expect a conversion method of some sort...

like image 371
Howie Avatar asked Sep 24 '12 07:09

Howie


2 Answers

string uriPath =
    "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj";
string localPath = new Uri(uriPath).LocalPath;
like image 142
Marc Gravell Avatar answered Oct 22 '22 00:10

Marc Gravell


Try This

ImagePath = "http://localhost/profilepics/abc.png";
   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath);
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream receiveStream = response.GetResponseStream();
like image 35
Hardeep Singh Avatar answered Oct 22 '22 00:10

Hardeep Singh