I am a beginner in C #. Today is three days !!! Encountered a problem!
When I read the HTML source code, I found an example and used stream to read it, but the byte cannot be saved. I found another solution:
Byte [] Buf = new byte [1, 1024];
String test = "";
Int COUNT = 0;
Httpwebrequest request = (httpwebrequest) webrequest. Create ("http://www.163.com ");
Httpwebresponse response = (httpwebresponse) request. getresponse ();
Stream resstream = response. getresponsestream ();
While (true)
{
Count = resstream. Read (BUF, 0, Buf. Length );
// Exit the loop after reading.
If (count <= 0)
Break;
// Convert the number of bytes read to a string
Test + = encoding. ASCII. getstring (BUF, 0, count );
}
Now the string test stores the complete HTML, which is recorded !!!
As I am a newbie, I hope you can find a better solution. Don't hesitate to give me some advice !!!