This document is archived and information here might be outdated.  Recommended version.


How to enable DGN files with any extension (ArcObjects .NET 10.5 SDK)

How to enable DGN files with any extension


Summary
This topic shows how to programmatically set the computer-aided design (CAD) DGN setting that instructs ArcMap and ArcCatalog to examine all files for the DGN format. The results of the code are printed to the console for demonstration purposes. This setting can also be set manually by the user with the graphical interface for Options on the CAD tab.

Enabling DGN files with any file extension

To enable DGN files, follow these steps:
  1. Instantiate a CAD Workspace Factory.
  2. Cast the workspace factory to the ICadSettings interface.
  3. Set the EnableAllDgnFileExtensions property to true to enable support to examine all files for the DGN format.
See the following code:
[C#]
//Set CadSettings to a new CadWorkspaceFactory.
ESRI.ArcGIS.DataSourcesFile.ICadSettings pCadSettings=new
    ESRI.ArcGIS.DataSourcesFile.CadWorkspaceFactory()as
    ESRI.ArcGIS.DataSourcesFile.ICadSettings;
//Enable support to examine all files for DGN format.
pCadSettings.EnableAllDgnFileExtensions=true;
//Print the results to the console.
Console.WriteLine("EnableAllDgnFileExtensions={0}",
    pCadSettings.EnableAllDgnFileExtensions);
[VB.NET]
'Set CadSettings to a new CadWorkspaceFactory.
Dim pCadSettings As ESRI.ArcGIS.DataSourcesFile.ICadSettings=TryCast(New ESRI.ArcGIS.DataSourcesFile.CadWorkspaceFactory(), ESRI.ArcGIS.DataSourcesFile.ICadSettings)
'Enable support to examine all files for DGN format.
pCadSettings.EnableAllDgnFileExtensions=True
'Print the results to the console.
Console.WriteLine("EnableAllDgnFileExtensions={0}", pCadSettings.EnableAllDgnFileExtensions)






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced