public static string Escape(string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder(); int len = str.Length; for (int i = 0; i <len; i++) { char c = str[i]; //everything other than the optionally escaped chars _must_ be escaped if (Char.IsLetterOrDigit(c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') sb.Append(c); else sb.Append(Uri.HexEscape(c)); } return sb.ToString(); } public static string UnEscape(string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder(); int len = str.Length; int i = 0; while (i != len) { if (Uri.IsHexEncoding(str, i)) sb.Append(Uri.HexUnescape(str, ref i)); else sb.Append(str[i++]); } return sb.ToString(); }
自訂搜尋
2009/09/12
C# JS的Escape和UnEscape *0*
2009/09/06
C# 預設輸入法~~
InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages; foreach (InputLanguage il in ilc) { //中文 (繁體) - 美式鍵盤 //中文 (繁體) - 注音 //中文 (繁體) - 新注音 if (il.LayoutName == "中文 (繁體) - 新注音") { InputLanguage.CurrentInputLanguage = il; } }
C# 用WMI控制開機重啟
ref system.management
重啟 Reboot
using system.management;
ManagementClass mc_os = new ManagementClass("Win32_OperatingSystem"); mc_os.Scope.Options.EnablePrivileges = true; foreach (ManagementObject mo in mc_os.GetInstances()) { mo.InvokeMethod("Shutdown", null, null); } mc_os.Dispose();
重啟 Reboot
訂閱:
文章 (Atom)
讀取中…