在不同的操作系统下如何正确得到当前使用中的桌面路径?
RegistryKey folders;
folders = OpenRegistryPath(Registry.CurrentUser, @"/software/microsoft/windows/currentversion/explorer/shell folders");
// Windows用户桌面路径
string desktopPath = folders.GetValue("Desktop").ToString();
zm1.Text = desktopPath;
string filePath2 = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
zm2.Text = filePath2;
这2种写法得到的都是:
C:\Documents and Settings\Default User\桌面
而不是当前使用中的桌面:
C:\Documents and Settings\Krl\桌面
在windows 2003 server 或者2008的操作系统下得不到当前使用中的桌面,怎么办?
或者说,在保存导出的Excel文件时候如何让弹出一个保存框来保存到任意位置?