//获取文件夹:“C:UsersAdministratorAppDataRoaming”
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
//获取path文件夹及其子文件夹内所有dwg文件
var files = Directory.GetFiles(path, "*.dwg", SearchOption.AllDirectories);
//获取注册表:HKEY_LOCAL_MACHINESOFTWAREAutodeskHardcopy
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) { if (hklm != null) { using (var key = hklm.OpenSubKey(@"SOFTWAREAutodeskHardcopy")) { if (key != null) { var values = key.GetValueNames(); } } }
//获取注册表:HKEY_LOCAL_MACHINESOFTWAREAutodeskHardcopy
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using (var hkcu = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64)) { if (hkcu != null) { using (var key = hkcu.OpenSubKey(@"SoftwareAutodeskAutoCADR19.1ACAD-D001:804ProfilesTArch9General")) { if (key != null) { var cadPrinterConfigDir = key.GetValue("PrinterConfigDir"); } } } }