반응형

protected void SendReq(string htmlfile)
 {
 
     HttpWebRequest httpWebRequest =
         (HttpWebRequest)WebRequest.Create("http://www.abc.co.kr/" + htmlfile + ".htm");
     // 인코딩 1 - UTF-8
 
     //httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
     // 인코딩 2 - EUC-KR
 
     httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
     httpWebRequest.Method = "POST";
 
 
     Stream requestStream = httpWebRequest.GetRequestStream();
 
     requestStream.Close();
 
     HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
     StreamReader streamReader = 
         new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("EUC-KR"));    
     // Encoding.GetEncoding("EUC-KR")
     string html = streamReader.ReadToEnd();
     streamReader.Close();
     httpWebResponse.Close();
 
     //text.Value = html;
     richTextBox1.AppendText(html);
     savefile(htmlfile,html);
 
 }
 protected void savefile(string savename, string html)
 {
     FileStream fileStream = new FileStream(savename + ".htm", FileMode.Create, FileAccess.Write);
     StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.GetEncoding("EUC-KR"));
     //streamWriter.Write(richTextBox1);
 
     //richTextBox1.AppendText(result);
 
     //streamWriter.Write(html);
     streamWriter.Write(richTextBox1.Text);
     streamWriter.Close();
     fileStream.Close();
 }
원문 : http://jameroid.tistory.com/entry/c-%EC%9B%B9-%ED%8E%98%EC%9D%B4%EC%A7%80-html-%EB%B0%9B%EC%95%84%EC%84%9C-%EC%A0%80%EC%9E%A5%ED%95%98%EA%B8%B0

반응형

+ Recent posts