PIXNET Logo登入

Robert 的部落格

跳到主文

歡迎光臨Robert 在痞客邦的小天地

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 1月 11 週四 201810:17
  • [Reg][C#] 關於登錄檔概念、C#程式操作

好文暫存:C#綜合揭祕—通過修改登錄檔建立Windows自定義協議
原文(簡體):C#综合揭秘——通过修改注册表建立Windows自定义协议
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(80)

  • 個人分類:C#
▲top
  • 1月 11 週四 201809:12
  • [程式][C#] 目錄依次遞減刪除檔案與資料夾

在安裝程式中,有時會遇到它的設計是:
移除的檔案 若所在的資料夾 有其他檔案或資料夾,就只把安裝的檔案刪除,仍留下其他(可能是使用者自己放進去)的檔案/資料夾。
以下是用程式實作的範例:
using System.IO;
// ...
    private void DeleteAFile( string fileNamePath )
{
if ( File.Exists( fileNamePath ) )
File.Delete( fileNamePath );
string dirName = Path.GetDirectoryName( fileNamePath );
DirectoryInfo di = null ;
if ( Directory.Exists( dirName ) )
di = new DirectoryInfo( dirName );
while ( di != null && di.Parent != null )
{
if ( di.GetFiles().Length == 0
&& di.GetDirectories().Length == 0 )
{
di.Delete();
}
di = di.Parent;
}
} // DeleteAFile()
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(183)

  • 個人分類:C#
▲top
  • 1月 09 週二 201815: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;
}
}
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(317)

  • 個人分類:C#
▲top
  • 12月 21 週四 201715: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'.
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(96)

  • 個人分類:C#
▲top
  • 12月 21 週四 201714:33
  • [程式][C#] 寫入文字檔的方法(含新增文字檔)

目前知道的有:
System.IO.StreamWriter
System.IO.File.WriteAllLines
System.IO.File.WriteAllText
System.IO.File.CreateText
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(16,569)

  • 個人分類:C#
▲top
  • 12月 21 週四 201714:13
  • [程式][C#] 如何..建立資料夾+檔案?

後來才知道,不存在的路徑+檔案,是無法一次建立的。(目前所知)
 
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(4,739)

  • 個人分類:C#
▲top
  • 12月 21 週四 201714:00
  • [程式][C#] 如何取得當前使用者的資料夾(目錄)?

string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName;
if ( Environment.OSVersion.Version.Major >= 6 ) { // 判斷是不是Vista以上.
path = Directory.GetParent(path).ToString();
}
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(471)

  • 個人分類:C#
▲top
  • 12月 18 週一 201711:41
  • [程式][C#] 如何開啟使用者的預設瀏覽器?

原來這麼簡單...
Process.Start(@"http://www.google.com");
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(537)

  • 個人分類:C#
▲top
  • 12月 13 週三 201711:43
  • [程式][C#] 如何 確保/得知 WebBrowser(控制項) 已完成載入頁面?

webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
//This line is so you only do the event once
if (e.Url != webBrowser1.Url)
return;
//do you actual code
}
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(96)

  • 個人分類:C#
▲top
  • 12月 13 週三 201711:38
  • [程式][C#] 如何檢查字串為合法的HTTP URL?

Uri uriResult;
bool result = Uri.TryCreate(uriName, UriKind.Absolute, out uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
參考:How to check whether a string is a valid HTTP URL?
(繼續閱讀...)
文章標籤

Robert 發表在 痞客邦 留言(0) 人氣(872)

  • 個人分類:C#
▲top
123»

個人資訊

Robert
暱稱:
Robert
分類:
數位生活
好友:
累積中
地區:

最新文章

  • 工作繪圖 軟體清單
  • 套用主題
  • 比對 Powerpoint
  • GCPUG KH Meetup 系列 (2009)
  • 程式語言調查
  • 時區地圖
  • 相關資料
  • 一些連結
  • SoftEther VPN Server 忘記密碼
  • [VPN][SoftEther] 功能強大的VPN軟體工具分享,架設VPN Server首推!

熱門文章

  • (33,240)[程式][JS][HTML] 設定/取得 下拉選單(select)選取的項目(option)
  • (9,094)[程式][C#] 已存入Dictionary的值怎麼取呢?
  • (4,652)[程式][IDE][Eclipse] 編碼設定
  • (2,939)[程式][C#][WinForm][Web] 如何用post上傳檔案,含參數?
  • (1,915)[程式][C#] C# Singleton
  • (1,321)[程式][C#] 不區分大小寫 比對字串
  • (872)[程式][C#] 如何檢查字串為合法的HTTP URL?
  • (783)[程式][JSTL] 寫for迴圈
  • (672)[程式][JS][HTML] HTML5 使用postMessage在不同網頁之間傳送文字訊息
  • (573)[高雄捷運] 測量行駛時間 信義國小站(O6) ~ 大寮站(OT1)

文章搜尋

文章分類

toggle TODO (2)
  • Study (1)
  • 記事 (1)
toggle 學科 (1)
  • 資訊 (1)
toggle 資訊安全 (1)
  • 勒索病毒 (2)
toggle 數位生活 (8)
  • 工作繪圖 (1)
  • 通訊 (1)
  • VPN (1)
  • 網路 (4)
  • 閒聊 (1)
  • Windows (3)
  • Email (1)
  • 中英名詞對照 (2)
toggle 生活 (1)
  • 交通 (1)
toggle 軟體學習 (6)
  • Notepad++ (1)
  • 瀏覽器(Browser) (1)
  • Windows (5)
  • Office (1)
  • SoftEther (1)
  • OCR 光學字元辨識 (1)
toggle 程式開發 (25)
  • Browser (1)
  • JSP (3)
  • IDE (9)
  • PostMan (1)
  • 時間相關 (1)
  • 一般 (1)
  • TensorFlow (1)
  • C# (23)
  • ASP.NET (2)
  • Windows Forms (5)
  • jQuery (1)
  • JavaScript (13)
  • JSTL (4)
  • SQL (6)
  • HTML (6)
  • CSS (1)
  • 安裝檔打包 (10)
  • 工具 (2)
  • 細項 (2)
  • 程式語言 (1)
  • 程式設計 (6)
  • VSTO (4)
  • Azure (4)
  • Java (13)
  • IIS (2)
toggle 技術問題 (3)
  • 部落格 (1)
  • .NET 程式執行問題 (1)
  • 尋求支援與自助 (2)
  • 未分類文章 (1)

文章精選

參觀人氣

  • 本日人氣:
  • 累積人氣:

pixGoogleAdsense1

pixGoogleAdsense2