把FeatureClass存为一个shp文件

 
        public void saveFeatureClass(IFeatureClass pFeatureClass, string fileName)  
        {   
                string sFileName = System.IO.Path.GetFileName(fileName);  
                string sFilePath = System.IO.Path.GetDirectoryName(fileName);  
 
                IDataset pDataset = pFeatureClass as IDataset;  
                  
                IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();  
                IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFilePath, 0) as IFeatureWorkspace;  
 
                IWorkspace pWorkspace = pFeatureWorkspace as IWorkspace;  
                if (pWorkspace.Exists() == true)  
                {   
                    //删除

                   DelFeatureFile(sFilePath, sFileName);   

                }  
                pDataset.Copy(sFileName, pFeatureWorkspace as IWorkspace);  
 
            }   
          

public static void DelFeatureFile(string sDir, string sName)  
        {  
            IFeatureClass pFeatCls = GetFeatureClassByFileName(sDir + sName);  
            if (pFeatCls != null)  
            {  
                IDataset dataset = pFeatCls as IDataset;  
                dataset.Delete();  
            }  
 
        }

 


 

posted @ 2010-07-01 10:23  zhh  阅读(523)  评论(0编辑  收藏  举报