Time of Update: 2016-11-11
asp.net在伺服器端運行,是不能在伺服器端彈出對話方塊的,但是C#可以通過在頁面輸出JS代碼實現彈出訊息框的效果,這個C#類封裝了常用的訊息框彈出JS代碼,可以在伺服器端調用,在用戶端顯示對話方塊。不但可以顯示JS的警告框,還可以顯示模式視窗,非常方便。using System;using System.Web;using System.Web.UI;using System.Web.UI.WebControls; namespace DotNet.Utilities{ ///
Time of Update: 2016-11-11
這個C#代碼主要講iTextSharp中用於操作PDF檔案的方法進行了再次封裝,可以更加方便的訪問PDF文檔,可以動態產生PDF檔案、新增內容、設定段落、設定字型等。using System.IO;using iTextSharp.text;using iTextSharp.text.pdf; namespace DotNet.Utilities{ /// /// PDF文檔操作類 /// //------------------------------------
Time of Update: 2016-11-11
這個C#封裝類可以用於將各種格式的資料轉換成JSON格式,包括List轉換成Json,普通集合轉換Json ,DataSet轉換為Json ,Datatable轉換為Json ,DataReader轉換為Json等,如果你需要將對象轉換成JSON,可以使用這個類。using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Reflection;using
Time of Update: 2016-11-11
#include #include #include #include "utlist.h" #define BUFLEN 20 typedef struct el { char bname[BUFLEN]; struct el *next, *prev;} el; int namecmp(el *a, el *b) { return strcmp(a->bname,b->bname);} el *head = NULL; /* important-
Time of Update: 2016-11-10
FileStream aFile = new FileStream(SingleFile, FileMode.Open);StreamReader sr = new StreamReader(aFile, Encoding.GetEncoding("gb2312"), true);string FileContent = sr.ReadToEnd();aFile.Close();ProcessData Pd = new
Time of Update: 2016-11-10
C#編寫的一個反向 Proxy工具,可以緩衝網頁到本地proxy.ashx 主檔案 using System;using System.Web;using System.Net;using System.Text;using System.IO;using System.Collections.Generic;using System.Configuration; /// /// 把http headers 和 http 響應的內容 分別儲存在 /proxy/header/ 和
Time of Update: 2016-11-10
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO; namespace Calc24Points{ public class Cell { public enum Type { Number, Signal } public int
Time of Update: 2016-11-10
public class BinaryTreeNode{ public BinaryTreeNode Left { get; set; } public BinaryTreeNode Right { get; set; } public int Data { get; set; } public BinaryTreeNode(int data) { this.Data = data; }} public void
Time of Update: 2016-11-10
C#分別用前序走訪、中序遍曆和後序遍曆列印二叉樹public class BinaryTreeNode{ public BinaryTreeNode Left { get; set; } public BinaryTreeNode Right { get; set; } public int Data { get; set; } public BinaryTreeNode(int data) { this.Data = data; }
Time of Update: 2016-11-10
public static string GetMD5(string sDataIn) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] bytValue, bytHash; bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
Time of Update: 2016-11-10
using System;using System.Collections.Generic;using System.Linq;using System.Text;using MySql.Data.MySqlClient;using System.Data;class MySqlHelper:IDisposable { private MySqlConnection m_conn = null; private MySqlTransaction m_trans
Time of Update: 2016-11-10
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Text;using System.Windows.Forms; namespace 讀取host檔案{ public partial class Form1 : Form {
Time of Update: 2016-11-10
#region 識別urlStr是否是網路路徑 /// /// 識別urlStr是否是網路路徑 /// /// /// public static bool UrlDiscern(string urlStr) { if (Regex.IsMatch(urlStr, @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2
Time of Update: 2016-11-10
寫類庫項目時,經常會有某些特殊業務需要用到伺服器端的實體路徑,使用傳統的 System.IO.Directory.GetCurrentDirectory()方法返回的則是WINNT\System32目錄,這個一般不能滿 足正常的業務需求,而要得到具體運行DLL所在的物理目錄可以通過Assembly.GetExecutingAssembly().CodeBase屬 性來取得,具體參考方法如下:/// /// 擷取Assembly的運行路徑 /// /// private
Time of Update: 2016-11-10
private void Form1_Load(object sender, EventArgs e) { object ppvComObject = null; try { Guid CLSID_ShellWindows = new Guid("9BA05972-F6A8-11CF-A442-00A0C90A8F39"); Type pComType =
Time of Update: 2016-11-10
using System;using System.IO;string filetomerge=@"C:\temp\data.bin";string targetpath=@"D:\store";string strFileName = filetomerge.Substring(filetomerge.LastIndexOf(Path.DirectorySeparatorChar) + 1);FileStream fsr1 = new FileStream(targetpath+
Time of Update: 2016-11-10
using System.IO;using System.Windows.Forms; OpenFileDialog dlg = new OpenFileDialog();dlg.Filter ="All files (*.*)|*.*";dlg.FilterIndex = 1;dlg.RestoreDirectory = true;dlg.Multiselect = true;if (dlg.ShowDialog() == DialogResult.OK){ foreach
Time of Update: 2016-11-10
這項API提供的實用功能常常用來管理應用程式中的服務,而不必到控制台的管理服務中進行操作。ServiceController controller = new ServiceController(“e-M-POWER”); controller.Start(); if (controller.CanPauseAndContinue) { controller.Pause(); controller.Continue();
Time of Update: 2016-11-10
用下面的方法,可以檢查.NET給程式分配的記憶體數量long available = GC.GetTotalMemory(false);Console.WriteLine(“Before allocations: {0:N0}”, available);int allocSize = 40000000;byte[] bigArray = new byte[allocSize];available =
Time of Update: 2016-11-10
比如我們鎖定系統後,如果QQ沒有退出,則它會顯示了忙碌狀態。請添加命名空間Microsoft.Win32,然後對註冊下面的事件。. DisplaySettingsChanged (包含Changing) 顯示設定. InstalledFontsChanged 字型變化. PaletteChanged. PowerModeChanged 電源狀態. SessionEnded (使用者正在登出或是會話結束). SessionSwitch (變更目前使用者). TimeChanged 時間改變.