반응형
예외 :“URI 형식은 지원되지 않습니다.”
dir을 가리키는 절대 로컬 경로가 있습니다. "file:\\C:\\Users\\john\\documents\\visual studio 2010\\Projects\\proj"
그러나 내가 그것을 DirectoryInfo
의 ctor 에 던지 려고하면 "URI 형식이 지원되지 않습니다"예외가 발생합니다.
나는 검색하고 그렇게 보았지만 로컬 경로가 아닌 원격 경로가있는 솔루션 만 봅니다. 나는 일종의 변환 방법을 기대합니다 ...
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();
http : /// www 대신 실제 파일 경로를 얻기 위해 Path.Combine (MapPath ())와 동일한 오류를 해결했습니다 .
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 { }
참고 URL : https://stackoverflow.com/questions/12560664/exception-uri-formats-are-not-supported
반응형
'program tip' 카테고리의 다른 글
Apache HttpClient를 사용하여 JSON 요청을 게시하는 방법은 무엇입니까? (0) | 2020.09.16 |
---|---|
SQLITE SQL 덤프 파일을 POSTGRESQL로 변환 (0) | 2020.09.16 |
LocalDate를 Instant로 변환하는 방법? (0) | 2020.09.16 |
.Net에서 PDF 문서 읽기 (0) | 2020.09.16 |
Windows에서 Python 2.6 용 Setuptools를 설정하려면 어떻게해야합니까? (0) | 2020.09.16 |