C#, C♯, C#相談室 Part64

このエントリーをはてなブックマークに追加
474デフォルトの名無しさん
private void reloadpage_bg()
{
string webad = "";
webad = "http://www.hoge.net/hoge.pl?dummy="+DateTime.Now.ToString("yyyyMMddHHmm");
webBrowser1.Navigate(webad,false);
webBrowser1.Refresh(WebBrowserRefreshOption.Completely);
System.Text.Encoding dest = System.Text.Encoding.UTF8;
len = (int)webBrowser1.DocumentStream.Length;
string webcode ="";
//webcode = webBrowser1.DocumentText;
byte[] buf = new byte[len];
webBrowser1.DocumentStream.Read(buf, 0, len);
Encoding ec = Encoding.GetEncoding(webBrowser1.Document.Encoding);
byte[] sjis_temp = System.Text.Encoding.Convert(ec, dest, buf);
string sjis_str = dest.GetString(sjis_temp);
try
{
int cback = sjis_str.IndexOf(")</span>");
webcode = sjis_str.Remove(cback);
int cfront = webcode.IndexOf(" <span>(");
webcode = webcode.Remove(0, cfront + 13);
webcode = DateTime.Now.ToString("D") + "," + DateTime.Now.ToString("t") + "," + webcode;
StreamWriter writer = new StreamWriter(fnam, true, Encoding.GetEncoding("Shift_JIS"));
writer.WriteLine(webcode);
writer.Close();
}
catch
{
stopflag = 1;
}
}