檔案“D:\Log\Cargoabc\logfilecargoabc.txt”正由另一進程使用,因此該進程無法訪問該檔案。logfilecargoabc.txt是一個記錄檔,不定時都可能由另外的程式對它進行日誌記錄寫入操作。今需要對記錄檔讀取出來,顯示在日誌查詢裡,需要用到了IO流。1、 FileStream fs = File.OpenRead(url);StreamReader sr = new StreamReader((System.IO.Stream)fs,
C#中使用JSON不需要使用第三方庫,使用.NET Framwork3.5內建的System.Runtime.Serialization.Json即可很好的完成JSON的解析。關於JSON的入門介紹見(首頁的圖很形象):http://www.json.org/ 一、Using需要添加引用:System.ServiceModel.Web 和 System.Runtime.Serialization,然後使用Using:Code highlighting produced by Actipro
關於C#中的自訂事件產生:目標:通過一個執行個體來按步驟說明C#中如何建立,引發,接收和取消事件。例子是一個表單程式,一個按鈕和一個標籤,點擊按鈕的時候就觸發一個事件得到目前時間,如果秒是後30秒就輸出一個Wasn't a right time!!一,建立一個事件類型:1,建立一個表單應用程式,添加一個button和lebelInfo,name分別為buttonRaise和labelInfo。2,定義一個委託:在表單類的聲明部分添加,public delegate void
通常swap(a,b),都是用中間變數public static void Swap1(ref int a, ref int b) { int temp = a; a = b; b = temp; }產生的IL如下(去除ref) .maxstack 1 .locals init ( [0] int32 temp) L_0000: ldarg.0 L_0001:
1. 摘要在這篇文章中,我會通過IL去分析一個簡單的語句。如果覺得實在簡單,可以略過。2. 引子事情是這樣的,同事寫了一段類似這樣的代碼:class Program{ static void Main(string[] args) { object o = new object(); int i; Int32.TryParse(Console.ReadLine(), out
//需要添加System.Drawing及System.Windows.Forms引用 using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Windows.Forms; namespace 網頁 { class Program { [STAThread]