工作空间工厂 打开文件例子
//IWorkspaceFactory OpenFromFile Example
//e.g., nameOfFile = "E:\\data\\english\\access\\canada\\canada.mdb"
public IWorkspace IWorkspaceFactory_OpenFromFile_Example_Access(string nameOfFile)
{
IWorkspaceFactory workspaceFactory= new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
return workspaceFactory.OpenFromFile(nameOfFile, 0);
}
//e.g., nameOfFile = "E:\\data\\english\\FileGDB\\canada\\canada.gdb"
public IWorkspace IWorkspaceFactory_OpenFromFile_Example_FileGDB(string nameOfFile)
{
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
return workspaceFactory.OpenFromFile(nameOfFile, 0);
}
//e.g., nameOfFile = "D:\\data\\redarrow.sde"
public IWorkspace IWorkspaceFactory_OpenFromFile_Example_ArcSDE(string nameOfFile)
{
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
return workspaceFactory.OpenFromFile(nameOfFile, 0);
}
//The connection string for a shapefile should be the full path
//to the Shapefile's folder (e.g., "C:\\temp")
// Note: location cannot be relative path ".\\temp" it must be an explicit pathname
public IWorkspace IWorkspaceFactory_OpenFromFile_Example_Shapefile(string nameOfFile)
{
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
return workspaceFactory.OpenFromFile(nameOfFile, 0);
}