Using ArcObject programming, we can develop the following type of applications.
- Standalone Application - Standalone applications return the Executable file (.exe). For a standalone application, we don't need to open the ArcGIS application; we can directly execute the .exe file.
- ArcGIS Command or Tool - The output of this application is a .dll and a .tlb file. For dll, we have to first run the ArcGIS application because the dll file will work within the ArcGIS process memory.
The above-mentioned applications have separate development flow so, in Standalone application development, we start from Workspace factory object while in ArcGIS Command or Tool application development, we start from the Application object. So, in this blog, I am explaining how we can create an object of workspace using Propertyset which we can create in following two ways. I will explain the second flow of creating workspace object in my other blogs.
- using workspace factory OpenfromFile() method
- using workspace IPropertyset
If we want to create an object of workspace using property set and we have Personal Geodatabase as input, below are the steps we have to follow.
- Create an object of workspace factory using appropriate Abstract class.
- Create an IPropertyset object.
- Set the property in IPropertyset .
- Use method Open() which is available in workspace factory object. This method returns an object of the workspace.
Used Interfaces
IPropertySet , IWorkspaceFactory, IWorkspace
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using ESRI.ArcGIS.DataSourcesFile;
- using ESRI.ArcGIS.DataSourcesGDB;
- using ESRI.ArcGIS.Geodatabase;
- using ESRI.ArcGIS.esriSystem;
- using ESRI.ArcGIS.Geometry;
- using System.Collections;
- namespace WindowsApp {
- public partial class Form1: Form {
- public Form1() {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e) {
- ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
- propertySet.SetProperty("DATABASE", @ "D:\YS\GDB\test.mdb");
- IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
- IWorkspace pes = workspaceFactory.Open(propertySet, 0);
- }
- }
- }