Exception: “URI formats are not supported”

后端 未结 4 1028
误落风尘
误落风尘 2020-12-08 01:40

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

But when I try

相关标签:
4条回答
  • 2020-12-08 02:06

    Try This

    ImagePath = "http://localhost/profilepics/abc.png";
       HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ImagePath);
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream receiveStream = response.GetResponseStream();
    
    0 讨论(0)
  • 2020-12-08 02:11

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

    0 讨论(0)
  • 2020-12-08 02:20
         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 { }
    
    0 讨论(0)
  • 2020-12-08 02:23
    string uriPath =
        "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj";
    string localPath = new Uri(uriPath).LocalPath;
    
    0 讨论(0)
提交回复
热议问题