我正在使用C#來獲取系統的字體文件夾的確切路徑。 找不到哪個類/ dll。如何獲取Windows字體文件夾的路徑?
10
A
回答
33
string fontsfolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Fonts);
注意的是,在SpecialFolder枚舉Fonts文件夾僅在.NET 4.0及以後可用。
5
Environment.SpecialFolders.Fonts
7
string fontFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
28
對於這裏指定Environment.SpecialFolders.Fonts
的答案,枚舉值只存在於.NET 4.0+中。
對於.NET 1.1 - 3.5,你可以做到以下幾點:
字體文件夾是Windows文件夾中(例如C:\ WINDOWS \字體)。編程抓住它通過下列步驟操作:
離鍵,它在.NET 2枚舉值存在,如系統文件夾
Environment.SpecialFolder.System
不同的特殊的文件夾。抓住系統文件夾的父文件夾(獲得基本的Windows文件夾)
串聯字體名稱到Windows文件夾,以獲得最終結果。
此代碼示例使用System文件夾並執行此操作。還有其他文件夾可以關閉。
using System.IO;
// get parent of System folder to have Windows folder
DirectoryInfo dirWindowsFolder = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.System));
// Concatenate Fonts folder onto Windows folder.
string strFontsFolder = Path.Combine(dirWindowsFolder.FullName, "Fonts");
// Results in full path e.g. "C:\Windows\Fonts"
相關問題
- 1. 如何在Mac OS X中獲取字體文件夾路徑?
- 2. 獲取文件夾路徑
- 3. 如何從給定文件夾路徑獲取文件夾路徑?
- 4. 獲取拖入Windows窗體窗體的文件的路徑
- 5. 如何將windows文件夾路徑轉換爲linux文件夾路徑
- 6. 如何獲取jar文件中的文件夾路徑?
- 7. 如何獲取res.drawable文件夾的路徑以複製文件?
- 8. 如何從文件路徑獲取父文件夾的名稱?
- 9. 如何在js文件中獲取文件夾「node_modules」的路徑?
- 10. 使用Actionscript獲取Windows文檔文件夾路徑
- 11. 如何在extjs中獲取文件夾路徑而不是文件路徑
- 12. 如何獲取我的項目中文件夾的路徑(以及該文件夾中文件的路徑)?
- 13. 獲取下載文件夾在Windows中的路徑java
- 14. 獲取Windows下載文件夾的路徑
- 15. 如何從文件輸入中獲取文件夾路徑?
- 16. 獲取當前文件夾路徑
- 17. 從路徑獲取文件夾名稱
- 18. 獲取特定文件夾路徑
- 19. 在jsp中獲取文件夾路徑
- 20. 獲取WordPress安裝文件夾路徑
- 21. delphi獲取文件夾路徑
- 22. asp.net獲取路徑頁文件夾URL
- 23. 獲取Vista文件夾路徑
- 24. 獲取文件夾圖標路徑
- 25. 獲取chrome文件夾路徑c#
- 26. 從文件夾路徑獲取Outlook中的MAPI文件夾
- 27. 如何獲取特定用戶的Windows「特殊文件夾」的路徑?
- 28. MFC CFileDialog - 在Windows 7上獲取特殊文件夾路徑
- 29. 在Windows窗體應用程序中獲取IIS文件夾物理路徑
- 30. 如何從德爾福的已知文件夾GUID獲取文件夾路徑