请参阅How to get the path to CSIDL_COMMON_DOCUMENTS in .NET 3.5?
它const int CSIDL_COMMON_DOCUMENTS = 0x002e;
提供的位置。
对于Fonts
文件夹,使用const int CSIDL_FONTS = 0x0014;
这将是:
[DllImport("shell32.dll"), CharSet = CharSet.Auto]
static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, uint dwFlags, [Out] StringBuilder pszPath);
const int CSIDL_FONTS = 0x0014;
const int CSIDL_FLAG_CREATE = 0x8000;
StringBuilder sb = new StringBuilder();
int retVal = SHGetFolderPath(IntPtr.Zero,
CSIDL_FONTS | CSIDL_FLAG_CREATE,
IntPtr.Zero,
0,
sb);
Debug.Assert(retVal >= 0); // assert that the function call succeeded
String folderLocation = sb.ToString();
我看不出为什么这不会在3.5工作...什么错误信息你好吗? – andypaxo
@andypaxo我已更新错误消息 – Anuya