Private Sub DeleteDataset() Dim pMxDocument As IMxDocument Dim pMap As IMap Dim pFeatureLayer As IFeatureLayer Dim pFeatureClass As IFeatureClass Dim pDataset As IDataset Dim pActiveView As IActiveView Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap ' Define the dataset to be deleted. Set pFeatureLayer = pMap.Layer(0) Set pFeatureClass = pFeatureLayer.FeatureClass ' Remove the layer from the active map. pMap.DeleteLayer pFeatureLayer ' Delete the dataset. Set pDataset = pFeatureClass pDataset.Delete ' Refresh the map. Set pActiveView = pMap pActiveView.Refresh End Sub
' This snippet is intended to be inserted at the base level of a Class. ' It is not intended to be nested within an existing Function or Sub. ' '''<summary>Deletes from a specified directory that match a certain pattern.</summary> ''' '''<param name="filePath">A System.String that is the file and path from where to delete files. Example: "C:\temp"</param> '''<param name="pattern"> A System.String that is the pattern for files to delete. Example: "*.txt" or "myfile.*" or "*.*"</param> ''' '''<remarks>All files meeting the pattern will be deleted from the specified directory.</remarks> Public Sub DeleteFilesFromDir(ByVal filePath As System.String, ByVal pattern As System.String) Dim directoryInfo As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(filePath) Dim files As System.IO.FileInfo() = directoryInfo.GetFiles(pattern) For Each file As System.IO.FileInfo In files file.Delete() Next End Sub