打开shpfile,mdb,sde工作空间
打开shapefile工作空间:
1 ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory(); 2 3 IWorkspace ws = wsf.OpenFromFile(Application.StartupPath, 0); 4 5 IFeatureClass f1 = (ws as IFeatureWorkspace).OpenFeatureClass("floodarea1");
打开mdb工作空间:
1 IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory(); 2 3 IWorkspace ws = wsf.OpenFromFile(Application.StartupPath+@"\test.mdb", 0); 4 5 IFeatureClass f1 = (ws as IFeatureWorkspace).OpenFeatureClass("floodarea1");
用IWorkspaceName打开mdb工作空间:
1 IPropertySet pPropSet = new PropertySetClass(); 2 pPropSet.SetProperty("DATABASE", strMdb); 3 IWorkspaceName pInWsName = new WorkspaceNameClass(); 4 pInWsName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory"; 5 pInWsName.ConnectionProperties = pPropSet; 6 7 IWorkspaceFactory pFact = new AccessWorkspaceFactoryClass(); 8 IWorkspace pWorkspace = pFact.Open(pPropSet, 0);
打开存储在oracle中的sde工作空间:
1 IWorkspace ws = null; 2 IPropertySet pPropSet = new PropertySetClass(); 3 IWorkspaceFactory pSdeFact = new SdeWorkspaceFactoryClass(); 4 5 string Server = "192.168.1.91"; 6 string Instance = "5151";//"esri_sde"; 7 string Database = "oracle"; 8 string User = "sde"; 9 string Password = "sde"; 10 string version = "SDE.DEFAULT"; 11 12 pPropSet.SetProperty("SERVER", Server); 13 pPropSet.SetProperty("INSTANCE", Instance); 14 pPropSet.SetProperty("DATABASE", Database); 15 pPropSet.SetProperty("USER", User); 16 pPropSet.SetProperty("PASSWORD", Password); 17 pPropSet.SetProperty("VERSION", version); 18 ws = pSdeFact.Open(pPropSet, 0); 19 20 IFeatureClass f1 = (ws as IFeatureWorkspace).OpenFeatureClass("floodarea1");