I created a function where I access to a Raster folder and get all files CRS
for Rsubdir, Rdirs, Rfiles in os.walk(Rrootdir):
for Rfile in Rfiles:
Rfile, Rextension = os.path.splitext(os.path.join(Rsubdir, Rfile).replace("\\", "/"))
if Rextension == '.tif':
RfileName = os.path.join(Rsubdir, Rfile).replace("\\", "/") + ".tif"
if os.path.isfile(RfileName):
RfileInfo = QFileInfo(RfileName)
RbaseName = RfileInfo.baseName()
Rlyr = QgsRasterLayer(RfileName,RbaseName)
coordR=Rlyr.crs().authid()
RasterCRS.append(coordR)
the problem is when I try to access the same folder files after this function call, I get a PermissionError
PermissionError: [WinError 32] Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus: 'chemin_fichier.tif'
which means that the files are always opened. is there any way to close them in the end of the function?