Tig*_*ran 37
string fontsfolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Fonts);
请注意,SpecialFolder枚举中的Fonts文件夹仅在.Net 4及更高版本中可用.
Joh*_*n K 28
对于此处指定的答案Environment.SpecialFolders.Fonts,枚举值仅存在于.NET 4.0+中.
对于.NET 1.1 - 3.5,您可以执行以下操作:
Fonts文件夹位于Windows文件夹中(例如C:\ Windows\Fonts).通过以下步骤以编程方式获取它:
键入.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"
string fontFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
| 归档时间: | 
 | 
| 查看次数: | 17581 次 | 
| 最近记录: |