WebRequest WebReq =WebRequest.Create(@"http://www.9630000.com/temp.txt");
WebReq.Method="GET";
WebResponse getWebReq=WebReq.GetResponse();
Stream respStream = getWebReq.GetResponseStream();
StreamReader reader = new StreamReader(respStream, Encoding.ASCII);
string GetDetail= reader.ReadToEnd();
respStream.Close();
GetDetail就是读出来的字符串,写到本地文件中应该会写了吧:)
WebReq.Method="GET";
WebResponse getWebReq=WebReq.GetResponse();
Stream respStream = getWebReq.GetResponseStream();
StreamReader reader = new StreamReader(respStream, Encoding.ASCII);
string GetDetail= reader.ReadToEnd();
respStream.Close();
GetDetail就是读出来的字符串,写到本地文件中应该会写了吧:)
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);
http://dotnet.aspx.cc/ShowDetail.aspx?id=0A6660CE-4138-41EF-B882-15DB65564709例子:
http://dotnet.aspx.cc/Exam/GetPageHtml.aspx