[C#]//IWorkspaceFactory Create Example
public void IWorkspaceFactory_Create_Example_Access()
{
// create a new Access workspace factory
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
// Create a workspacename with the workspace factory
IWorkspaceName workspaceName = workspaceFactory.Create("C:\\temp\\", "MyNewpGDB.mdb", null, 0);
// Cast for IName
ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)workspaceName;
//Open a reference to the access workspace through the name object
IWorkspace pGDB_workspace = (IWorkspace)name.Open();Console.WriteLine("Current path of the {0} is {1}", pGDB_workspace.Type, pGDB_workspace.PathName);
}
public void IWorkspaceFactory_Create_Example_FileGDB()
{
// create a new FileGDB workspace factory
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
// Create a workspacename with the workspace factory
IWorkspaceName workspaceName = workspaceFactory.Create("C:\\temp\\", "MyNewFileGDB.gdb", null, 0);
// Cast for IName
ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)workspaceName;
//Open a reference to the FileGDB workspace through the name object
IWorkspace fileGDB_workspace = (IWorkspace)name.Open();Console.WriteLine("Current path of the {0} is {1}", fileGDB_workspace.Type, fileGDB_workspace.PathName);
}
public void IWorkspaceFactory_Create_Example_ArcSDE()
{
ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
propertySet.SetProperty("Server", "testserver");
propertySet.SetProperty("Instance", "5151");
propertySet.SetProperty("Database", "sde"); //Ignored with ArcSDE for Oracle
propertySet.SetProperty("user", "sde");
propertySet.SetProperty("password", "go");
propertySet.SetProperty("version", "sde.DEFAULT");// create a new ArcSDE workspace factory
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
// Create a workspacename with the workspace factory
IWorkspaceName workspaceName = workspaceFactory.Create("C:\\temp\\", "MyNewArcSDE_Connection.sde",propertySet, 0);
// Cast for IName
ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)workspaceName;
//Open a reference to the FileGDB workspace through the name object
IWorkspace sde_workspace = (IWorkspace)name.Open();
//the path returned in this case will be for the sde connection
Console.WriteLine("Current path of the {0} is {1}", sde_workspace.Type, sde_workspace.PathName);
}
[Visual Basic 6.0, Visual Basic .NET, C++]
No example is available for Visual Basic 6.0, Visual Basic .NET, or C++. To view a C# example, click the Language Filter button
in the upper-left corner of the page.