Start ArcObject Programming To Create Workspace Using Ipropertyset

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.
  1. using workspace factory OpenfromFile() method
  2. 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.
  1. Create an object of workspace factory using appropriate Abstract class.
  2. Create an IPropertyset object.
  3. Set the property in IPropertyset .
  4. Use method Open() which is available in workspace factory object. This method returns an object of the workspace. 
Used Interfaces

IPropertySet , IWorkspaceFactory, IWorkspace
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Text;  
  7. using System.Windows.Forms;  
  8. using ESRI.ArcGIS.DataSourcesFile;  
  9. using ESRI.ArcGIS.DataSourcesGDB;  
  10. using ESRI.ArcGIS.Geodatabase;  
  11. using ESRI.ArcGIS.esriSystem;  
  12. using ESRI.ArcGIS.Geometry;  
  13. using System.Collections;  
  14. namespace WindowsApp {  
  15.     public partial class Form1: Form {  
  16.         public Form1() {  
  17.             InitializeComponent();  
  18.         }  
  19.         private void button1_Click(object sender, EventArgs e) {  
  20.             ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();  
  21.             propertySet.SetProperty("DATABASE", @ "D:\YS\GDB\test.mdb"); //Set the property of Ipropertyset  
  22.             IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();  
  23.             IWorkspace pes = workspaceFactory.Open(propertySet, 0); //Return object of workspace  
  24.         }  
  25.     }  
  26. }