2011-09-13 25 views

答えて

33
string fontsfolder = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Fonts); 

SpecialFolder列挙中Fontsフォルダがネット4とを超えてのみ利用可能であることに注意してください。

5
Environment.SpecialFolders.Fonts 
7
string fontFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts); 
28

Environment.SpecialFolders.Fontsを指定している回答の場合、その列挙値は.NET 4.0以降にのみ存在します。

FontsフォルダがWindowsフォルダ内にある(例えば、C:\ WINDOWS \フォント)を使用すると、次の操作を行うことができます3.5 - .NET 1.1の場合

。プログラムでこれらの手順を通してそれをつかむ:システムフォルダEnvironment.SpecialFolder.Systemのように、.NET 2の列挙値に存在しない別の特別なフォルダオフ

  1. キー。

  2. グラブシステムフォルダの親フォルダ(ベースのWindowsフォルダを取得します)

  3. は、最終的な結果を得るために、Windowsフォルダにフォント名を連結します。

このコードサンプルでは、​​システムフォルダを使用しています。あなたが鍵を掛けることができる他のフォルダがあります。

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" 
関連する問題