Time of Update: 2018-12-04
程式說明備忘: 整個程式是遠程啟動一個進程,然後再查詢進程列表,並顯示出來,然後遠程終止在列表中選擇的進程,這樣一個過程。private ManagementScope Ms = null; private ManagementObjectCollection Collection = null; private ArrayList processList = new ArrayList();if(null == Ms) { ConnectionOptions
Time of Update: 2018-12-04
快速排序,昨天上網找的演算法說明,今天用c#給實現的,確實蠻快,嘎嘎簡單說明:輸入第一個參數是要排序的數組,這裡我寫的是引用傳遞,用了ref修飾,其實這裡是不是引用傳遞不是關鍵,第二個和第三個參數指定要排序的起始和終止點,當然一般都是全排序啦,就指向數組頭和尾就行,注意num.Length這裡別忘了減一,不然可就越界了,數組是從0開始的~ private void checkNumOredASC(ref int[] num,int left,int right) {
Time of Update: 2018-12-04
1。根據連結訪問web需要匯入的包(不知道是不是應該這麼說,以前用JAVA的,說習慣了)System.Net具體代碼:String url = "http://127.0.0.1/CORID/Login.asp?MailAddress=" + textBox1.Text.Trim() + "&Password=" + textBox2.Text.Trim();WebRequest wrt = WebRequest.Create(url); /
Time of Update: 2018-12-04
添加模板工程1. 在plugins/com.nokia.cdt.templates_1.3.0.024/templates目錄裡,建立新模板工程,2. 修改template.xml.添加檔案:<parameter name="file" sourcePath="inc/RLog.h" targetPath="$(incDir)/RLog.h" /> 3. 修改plugin.xml<template
Time of Update: 2018-12-04
通過應用程式讀取網頁資訊的時候,通常需要抓取網頁的資料,但是有一個問題就是很多網頁需要登入後才能夠獲得頁面資料,那麼就需要儲存當前的cookie,在.NET中可以使用CookieContainer對象來儲存登入後的Cookie資訊,每次發送資料的時候加上Cookie資訊,就可以解決這個問題了。 #region 同步通過POST方式發送資料 /// <summary> ///通過POST方式發送資料 ///
Time of Update: 2018-12-04
string strServerIp="192.168.0.45";//為主機IP地址int iDataPort=80;Socket clientSocket =new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);bool bResult=clientSocket.Connect(new
Time of Update: 2018-12-04
按 F8 進入安全模式之,單擊 開始 -> 運行 regedit開啟註冊表,進入:HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run刪除鍵:BIE 其索引值為:Rundll32 C:/WINNT/DOWNLO~1/BDPlugin.dll,Rundll32(如果是win98,這裡的 C:/WINNT/DOWNLO~1/ 為
Time of Update: 2018-12-04
前幾天,在寫一個自動從XML中讀取數值並注入到對象屬性中去的時候,為了方便,不想把原來是int類型的寫與string類型,但是從XML裡讀取出來的時候,都是string類型。這時就需要將string類型自動地根據對象屬性的類型轉換過來。 比如string ==> int/long/double/DateTime/enum/String/bool.... 剛開始的時候,確實有點犯傻,來個長長的switch。 但是突然間想到,在使用asp.net
Time of Update: 2018-12-04
/// <summary> /// 啟動服務 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) {
Time of Update: 2018-12-04
在某些時候,例如:需要使用者輸入中文姓名的時候,需要驗證使用者輸入的是否全是中文,這個時候利用Regex,是一種比較理想的選擇 下面給出實現的方式: /// <summary> /// 需要引入 System.Text.RegularExpressions 命名空間 /// </summary> /// <param name="strInput">待驗證的字串</param> ///
Time of Update: 2018-12-04
服務安裝後事件 這樣就可以互動了private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) { ManagementBaseObject inPar = null; ManagementClass mc = new ManagementClass("Win32_Service"); foreach
Time of Update: 2018-12-04
ReferenceOrcas中C#語言的新特性:自動屬性,對象初始化器,和集合初始化器 新Orcas語言特性:擴充方法 1. 自動屬性: public class Person { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } }
Time of Update: 2018-12-04
using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;using System.Runtime.InteropServices;namespace ConsoleApplication22{ class Program { [DllImport("Ws2_32.dll")] public static extern uint
Time of Update: 2018-12-04
一個以前用的DES加密解密類突然解密的時候出現錯誤,怎麼搞都不行,後來找了個這個,雖然大致上差不多,但是這個確實可以的,真為以前的那個類鬱悶啊 using System;using System.Text;using System.Security.Cryptography; namespace Test{ /// <summary> /// DES加密 解密 /// </summary> public class DES {
Time of Update: 2018-12-04
C#裡面,重新命名檔案時,沒有 rename 這個功能,使用的是FileInfo.MoveTo的方式,MoveTo 到原目錄裡一個新的名字,即實現了重新命名 此方法用於重新命名檔案夾內的所有子檔案夾的名稱,新子檔案夾的名稱可以使用格式字串,如DIR{0:0000},重新命名後的子檔案夾為:DIR0001、DIR0002、DIR0003等。 具體使用方式見範例程式碼。 /// <summary> /// 重新命名檔案夾內的所有子檔案夾 /// </summary>
Time of Update: 2018-12-04
// ***** Tools public static string GetAppLocalDir() { string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string sonyDir = appDataDir + "//ace";
Time of Update: 2018-12-04
用C#實現實現簡單的 Ping 的功能,用於測試網路是否已經聯通1. 根據IP地址獲得主機名稱 /// <summary> /// 根據IP地址獲得主機名稱 /// </summary> /// <param name="ip">主機的IP地址</param> /// <returns>主機名稱</returns> public
Time of Update: 2018-12-04
#region 截取圖象 /// <summary> /// 從圖片中截取部分產生新圖 /// </summary> /// <param name= "sFromFilePath "> 原始圖片 </param> /// <param name= "saveFilePath "> 產生新圖 </param>
Time of Update: 2018-12-04
//**********以下代碼用SENDKEY開啟記事本寫資訊,儲存,關閉的例子*******開始********* private void button8_Click(object sender, EventArgs e) { Process txt = Process.Start(@"notepad.exe", @"d:/12.txt"); txt.StartInfo.WindowStyle =
Time of Update: 2018-12-04
1、新項目---服務程式2、灰視窗,屬性視窗ServeceName,給自己的服務起名字。3、代碼模式,OnStart,加入以下代碼: FileStream fs = new FileStream(@"d:/mcWindowsService.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter m_streamWriter = new StreamWriter(fs);