一、路徑分類
1、絕對路徑
完整路徑,從磁盤符號開始,如:C:\Windows
2、相對路徑
以當前路徑為起點,不包含磁盤符號,通常使用“..\”符號來訪問上級目錄中的文件或文件夾。
../Windows/System32
二、Windows系統常見的特殊路徑
1.當前路徑
2.我的文檔
3.收藏夾
4.桌面
5.最近使用的文檔
6.程序當前路徑
三、路徑獲取示例
1 private void btnGetCurPath_Click(object sender, EventArgs e) 2 { 3 txbCurProPath.Text = System.Windows.Forms.Application.StartupPath; 4 } 5 6 private void btnGetDesPath_Click(object sender, EventArgs e) 7 { 8 txbDesPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); 9 } 10 11 private void btnGetFaviratorPath_Click(object sender, EventArgs e) 12 { 13 txbFavorite.Text = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); 14 } 15 16 private void btnGetDcoPath_Click(object sender, EventArgs e) 17 { 18 txbDocPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 19 } 20 21 private void btnGetRecPath_Click(object sender, EventArgs e) 22 { 23 txbRecPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.Recent); 24 }