using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Geometry; namespace Arc_1 { public partial class Form1 : Form { private string path = @"D:\ArcObjects\myfGDB.gdb"; public Form1() { InitializeComponent(); } public static IWorkspace FileGdbWorkspaceFromPath(String path) { Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); return workspaceFactory.OpenFromFile(path, 0); } private void button1_Click(object sender, EventArgs e) { FileGdbWorkspaceFromPath(path); MessageBox.Show("You are connected now"); } } }
Solved! Go to Solution.
If you are using ArcGIS 10, then you also need to bind to a product before attempting to check out the license.
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_create_an_applic...