- Jan 10 Wed 2018 16:24
[Install][Windows] 安裝檔打包清單
- Jan 09 Tue 2018 15:56
[VSTO] 偵測"側窗"的關閉狀態
只有用「VisibleChanged」事件一途..。
Microsoft.Office.Tools.CustomTaskPane myTaskPane; public partial class MyControl : System.Windows.Forms.UserControl { // ... }
- Jan 09 Tue 2018 15:38
CPU Context Switch
Ready:排隊等待進入CPU被執行。
Runnung:正在被CPU執行。
Waiting:需要等待I/O存取的,離開CPU 在此等待。
- Jan 09 Tue 2018 15:26
[程式][C#] 測試連線到指定Server (HttpWebRequest)
public static bool IsConnectingServer() { string serverAddress = Properties.Settings.Default.ServerAddress; try { HttpWebRequest request = (HttpWebRequest) WebRequest.Create( serverAddress ); request.Method = "HEAD"; HttpWebResponse response = (HttpWebResponse) request.GetResponse(); return response.StatusCode == HttpStatusCode.OK; } catch ( Exception ) { return false; } }
- Dec 21 Thu 2017 15:46
[程式][C#] 取登錄檔(Registry)的值
舉例:
using System; using Microsoft.Win32; // ... string keyName = @"HKEY_CURRENT_USER\Software\Microsoft\..." // 相當於目錄. string manifestValue = (string) Microsoft.Win32.Registry.GetValue( keyName, "Manifest", null ); // 相當於檔案'Manifest'.
參考:Registry.GetValue 方法 (String, String, Object)
- Dec 21 Thu 2017 14:33
[程式][C#] 寫入文字檔的方法(含新增文字檔)
目前知道的有:
- System.IO.StreamWriter
- System.IO.File.WriteAllLines
- System.IO.File.WriteAllText
- System.IO.File.CreateText
System.IO.StreamWriter:
// 使用'using' 自動做Flush()、Close()、Dispose(), 釋放tw資源. using ( StreamWriter tw = new StreamWriter( "test.txt", true ) ) // 'true':新建或附加. { tw.WriteLine( "The next line!" ); } using ( StreamWriter tw = new StreamWriter( "test.txt", false ) ) // 'false',或沒填:新建或覆蓋. { tw.WriteLine( "The next line!" ); }
參考:Create a .txt file if doesn't exist, and if it does append a new line
- Dec 21 Thu 2017 14:13
[程式][C#] 如何..建立資料夾+檔案?
- Dec 21 Thu 2017 14:00
[程式][C#] 如何取得當前使用者的資料夾(目錄)?
string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName; if ( Environment.OSVersion.Version.Major >= 6 ) { // 判斷是不是Vista以上. path = Directory.GetParent(path).ToString(); }
來源:How can I get the current user directory?
參考:Operating System Version (version number)
備份:(2017/12/21)
- Dec 18 Mon 2017 13:38
[程式][WinForm][C#] 如何動態改變UI上的語言文字?
用 Visual Studio 開發 WinForm 的視窗程式介面時,專案有很方便的方式開發多語系介面。
但是,如果是在程式啟動、載入之後,才要變更語系呢?
在網路上搜尋、嘗試了一陣子,還沒找到方便的方法,只能刻苦耐勞地去刻:
- Dec 18 Mon 2017 11:41
[程式][C#] 如何開啟使用者的預設瀏覽器?