-4
last.fm에서 모든 앨범 아티스트를 다운로드하고 표지의 이름을 album으로 변경했습니다. 하지만 프로그램을 시작할 때 "잘못된 URI : URI가 비어 있습니다."라는 오류가 나타납니다.WebClient에서 많은 파일을 다운로드 할 수 없습니다. - 잘못된 URI : URI가 비어 있습니다.
프로그램 코드 :
public static void GetXML()
{
string url = @"http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&artist=radiohead&api_key=b25b959554ed76058ac220b7b2e0a026";
string albumName = String.Empty;
string coverLink = String.Empty;
int[] numArr = new int[30];
for (int x = 1; x < numArr.Length; x++)
{
numArr[x] = x;
}
XDocument xml = XDocument.Load(url);
foreach (var c in numArr)
{
var name = xml.XPathSelectElements(String.Format("//album[@rank='{0}']", c))
.Select(x => x.Element("name").Value)
.ToList();
foreach (var item in name)
{
albumName = item.ToString();
}
var covers = xml.XPathSelectElements(String.Format("//album[@rank='{0}']/image[@size='extralarge']", c))
.Select(x => x.Value)
.ToList();
foreach (var item in covers)
{
coverLink = item.ToString();
}
WebClient web = new WebClient();
web.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(web_DownloadFileCompleted);
web.DownloadFileAsync(new Uri(coverLink), @"X:\Code\T\" + albumName + ".jpg");
}
}
그래서? URI가 비어 있습니까? 그렇다면 언제 비어 있습니까? 코드를 수정하려고 시도한 것은 무엇입니까? – svick
라인은 무엇입니까? 디버그 안 했니? URI의 가치는 무엇이며 왜 비어있을 수 있습니까? 여기서 물어보기 전에 질문해야합니다. 디버깅을하고 결과를 질문에 쓰면 훨씬 더 좋은 답변을 얻을 수 있습니다. – Adam
코드에 버그가 있습니다. 찾아내는 것은 개발자에게 달렸습니다 (Visual Studio에서는 놓친 경우 통합 디버거를 제공함). 알아낼 수 없거나 과소 평가하지 않는 것에 대해 질문합니다. 다른 approch는 누군가를 지불하여 코드를 개발합니다. –