반응형
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(); }
반응형
'개발 Tip > C#' 카테고리의 다른 글
C# - 리소스에 포함된 데이터를 읽고 쓰자! (4) | 2013.02.27 |
---|---|
C#에서 WeifenLuo Docking 라이브러리 Visual Studio 2010에서 사용하기 (1) | 2010.05.20 |