看板 C_Sharp 關於我們 聯絡資訊
※ 引述《liptonbin (wind)》之銘言: : 請問我用HttpWebRequest HttpWebResponse : 怎麼有些原始碼顯示不出來 : 就是網頁原始碼中間有缺 但是其中的中文英文都正常顯示"沒有亂碼" : (只是會"少抓中間"的一些英文和中文字) : 我哪邊寫錯了嗎? 我把Encoding.UTF8改成Encoding.ASCII或Encoding.Default都會少 : 謝謝 : 程式如下 : private void button4_Click(object sender, EventArgs e) : { : HttpWebRequest hwRequest = (HttpWebRequest)HttpWebRequest.Create(m_url.Text); : HttpWebResponse hwResponse=(HttpWebResponse)hwRequest.GetResponse(); : System.IO.StreamReader sr = new : System.IO.StreamReader(hwResponse.GetResponse\ : Stream(), Encoding.UTF8); : int linen=0; : string line=""; : line = sr.ReadLine(); : while (line != null) : { : textBox2.Text += line+'\r'+'\n'; : line = sr.ReadLine(); linen++; : } : } 要不要改用 WebClient 試試看呢! 然後記得幫他們加上 Header ps. TextBox.Text 不適合拿來給你串接字串... 效率會非常非常差!!! 請先用 StringBuilder 串好再放進去 -- http://blog.roodo.com/chhuang -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.239.131
tomex:有讀書就知道StringBuilder的好 09/14 01:59