[英]Exception: “URI formats are not supported”
我有一个指向dir的绝对本地路径: "file:\\\\C:\\\\Users\\\\john\\\\documents\\\\visual studio 2010\\\\Projects\\\\proj"
但是当我尝试将它扔进DirectoryInfo
的ctor时,我得到了“不支持URI格式”的例外。
我用Google搜索并查看了SO,但我只看到了远程路径的解决方案,而不是本地解决方案。 我期待某种转换方法......
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();
我使用Path.Combine(MapPath())解决了相同的错误,以获取物理文件路径而不是http:/// www one。
string ImagePath = "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath);
string a = "";
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
if (receiveStream.CanRead)
{ a = "OK"; }
}
catch { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.