C'è qualcosa che non va, non cancella nessun file
codice:
<%
Dim objFso, objFolder, objFiles, strFolder, strFile
strPath = "/foto-prodotti"
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(Server.MapPath(strPath))
Set objFiles = objFolder.Files
For Each strFile in objFiles
'------------------------------------------------- INIZIO ciclo interno
sql = "select * from cataloghi"
set rec = conn.execute(sql)
if not rec.eof then
do while not rec.eof
productID = rec("productID")
PercorsoImg1 = rec("Foto1")
Dim fs
Set fs = Server.CreateObject("Scripting.FileSystemObject")
rec.MoveNext
RESPONSE.write "<br>----"
RESPONSE.write PercorsoImg1
RESPONSE.write "<br>----"
RESPONSE.write strPath & "/" & strFile.name
RESPONSE.write "<br>"
RESPONSE.write "<br>"
IF fs.FileExists (Server.MapPath(PercorsoImg1)) Then
IF strPath & "/" & strFile.name=Server.MapPath(PercorsoImg1) THEN fs.DeleteFile server.MapPath(PercorsoImg1),True
ELSE
response.write("NON ESISTE")
response.write("</br>")
END IF
Loop
end if
Set fs = nothing
rec.Close
set rec = nothing
'------------------------------------------------- FINE ciclo interno
Next
conn.Close
Set conn = nothing
Set objFso = Nothing
Set objFolder = Nothing
Set objFiles = Nothing
%>