Dear all,

I have some troubles wher I use in a pyqgis the function
QgsVectorFileWriter.deleteShapeFile(file_path)
here below the example:

def removeLayer(path_layer):
    # remove layer from TOC if already loaded
    basefile = os.path.basename(path_layer)
    diff_layer = os.path.splitext(basefile)[0]
    directory = os.path.dirname(path_layer)
    extensions = ["shp", "shx", "dbf", "prj", "sbn", "sbx", "fbn",
"fbx", "ain", "aih", "ixs", "mxs", "atx", "xml",
                  "cpg", "qix"]
    output_path=path_layer
    if os.path.exists(path_layer):
        if len(QgsProject.instance().mapLayersByName(diff_layer)) > 0:
            lyr = QgsProject.instance().mapLayersByName(diff_layer)[0]
            print('renaming layer1: ', lyr.id())
            QgsProject.instance().removeMapLayer(lyr.id())

        QgsVectorFileWriter.deleteShapeFile(path_layer)

Often some handles still remains and I'm not able to delete .dbf and .shp
files
How can I solve this error?

Thanks
Pierluigi

-- 
Ing. Pierluigi De Rosa (PhD in Earth Science)
Contract Professor of Geographic Information System at University of Perugia
cel: 3497558268 / fax: 075 7823038
skype: pierluigi.derosa
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to