当我经过
作为参数,下载的是 HTML 代码而不是视频。
public void StreamDownload(Uri currentUrl)
{
int dataLength;
int bytesRead;
WebRequest req = WebRequest.Create(currentUrl);
WebResponse response = req.GetResponse();
string oFileName = System.IO.Path.GetFileName(URLBox.Text);
oFileName = AdditionalFunctions.CorrectFname(oFileName); //this function replaces forbidden characters with '♥'.
Stream dataStream = response.GetResponseStream();
byte [] buffer = new byte[1024];
FileStream oFile = new FileStream(oFileName,FileMode.Append);
dataLength = (int)response.ContentLength;
do
{
bytesRead = dataStream.Read(buffer, 0, buffer.Length);
oFile.Write(buffer, 0, bytesRead);
}
while (bytesRead != 0);
}
由于评论而编辑
是否有从指定 URL 提取视频流的通用算法?Youtube 只是一个例子。