'选择一个矢量图形的文件夹,加载文件夹下所有的矢量图形到mapcontrol中去
Private Sub LoadFeatureLayers()
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatureWorkspace As IFeatureWorkspace
Dim pFeatureLayer As IFeatureLayer
Dim pMap As IMap
'Create a new ShapefileWorkspaceFactory object and open a shapefile folder
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(Me.txtInpathF, 0)
Dim strFileName As String
Dim strPathfilename As String
strPathfilename = Me.txtInpathF & "\*.shp"
strFileName = Dir(strPathfilename, vbDirectory) ' 找寻第一个文件名称,不包含路径
Do While strFileName <> "" ' 开始循环
'Create a new FeatureLayer and assign a shapefile to it
Set pFeatureLayer = New featurelayer
Set pFeatureLayer.featureclass = pFeatureWorkspace.OpenFeatureClass(strFileName)
pFeatureLayer.Name = pFeatureLayer.featureclass.AliasName
'Add the FeatureLayer to the focus map
Set pMap = Me.MapInterView.ActiveView.FocusMap
pMap.AddLayer pFeatureLayer
strFileName = Dir ' 查找下一个filename
Loop
End Sub