下载文件
下载文件
string sUri="http://www.wind-records.com.tw/product/mp3/s/tcd-6007-2.mp3";
WebRequest myWebRequest = WebRequest.Create(sUri); WebResponse myWebResponse = myWebRequest.GetResponse(); Stream ReceiveStream = myWebResponse.GetResponseStream();
运行到myWebRequest.GetResponse(); 就停了。
很久后就弹出“连接已经关闭”
想通过这样来下载,合适吗?
一般是怎么做的?
问题点数:20、回复次数:1Top
1 楼aiur2000(破愿立志别故里,荆棘南下思北风)回复于 2005-02-21 16:30:48 得分 20
msdn好又快
string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);
Top




