2015-06-29 47 views
0
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(videoInfoUrl); 
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 

Stream responseStream = response.GetResponseStream(); 
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")); 

string videoInfo = HttpUtility.HtmlDecode(reader.ReadToEnd()); 

NameValueCollection videoParams = HttpUtility.ParseQueryString(videoInfo); 

我的代碼:從HttpWebResponse response = await (HttpWebResponse)request.GetResponseAsync();如何在通用應用中下載YouTube視頻?

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(videoInforUrl); 
      // HttpWebResponse response = await (HttpWebResponse)request.GetResponseAsync(); 

      //Stream responseStream = response.GetResponseStream(); 
      //StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")); 

      //string videoInfor=HttpUtility 

我有問題顯示cannot convert httpwebresponse -> getresponseAsynce

普遍應用在HttpUtility

+1

在您被起訴或從商店中移除您的應用程序時在此處添加評論。你過去幾年沒有讀過這個消息嗎? – Behrooz

回答

0

不支持不要強迫你的打字。只要你能夠做到你想要的東西,就讓它返回它想要的東西。

擺脫了明確的類型像這樣的,你應該罰款:

var request = WebRequest.Create(videoInfoUrl); 
var response = await request.GetResponseAsync(); 

錯誤發生在,因爲你可能已經在錯誤的位置(HttpWebResponse)。如果你有它將試圖將TaskGetResponseAsync轉換爲響應,這就是爲什麼你會得到該錯誤。