整理一些小東西,留個備份

來源:互聯網
上載者:User

1.在winform中使用IE:
在工具箱裡右擊,選添加/刪除選項,在彈出的對話方塊裡選Com組件選項卡,找到Microsof Web瀏覽器組件,確定,
在工具箱裡選擇WebBrowser控制項,拖放到表單上,然後寫代碼:
private void button1_Click(object sender, System.EventArgs e)
{
 string str="";
 System.Object nullObject=0;
 System.Object nullObjStr=str;
 this.axWebBrowser1.Navigate("www.csdn.net",ref nullObject,ref nullObjStr,ref nullObjStr,ref nullObjStr);
   
}

2.修改xml節點值:
設xml文檔為:
<test>
<name>server</name>
</test>

XmlDocument doc = new XmlDocument();
doc.Load("sample.xml");
XmlNodeList nodes = doc.GetElementsByTagName("name");
nodes[0].InnerText = "NewValue";
doc.Save("sample.xml");

3.在類被析構時向log檔案中寫內容:
using System;
using System.IO;
using System.Data;
namespace finalize
{
 class test
 {
  string s = "aaa";
  ~test()
  {
   StreamWriter lastGasp;
   lastGasp = File.CreateText("yourLog.log");
   lastGasp.WriteLine("it's a log" + s);
   lastGasp.Flush();
   lastGasp.Close();
  }

  [STAThread]
  static void Main(string[] args)
  {
   test t = new test();
  }
 }
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.