例外:“不支持URI格式”

我有一个绝对的本地path指向一个目录: "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj"

但是当我试图把它扔进DirectoryInfo的ctor我得到“URI格式不支持”的例外。

我search了一下,然后看了看,但是我只能看到有远程path的解决scheme,而不是本地的解决scheme。 我希望有某种转换方法…

 string uriPath = "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj"; string localPath = new Uri(uriPath).LocalPath; 

尝试这个

 ImagePath = "http://localhost/profilepics/abc.png"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream();