Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630

    Elencare più estensioni in fso

    Carissimi,
    ho uno script per elencare file di una cartella su server tramite l'fso.
    Nell'impostazione dell'estensione da visualzzare ho solo un suffisso, cioè il pdf
    come posso aggiungere altri, tipo xls o doc etc
    Grazie
    G.
    La parte realtiva all'estensione è:
    codice:
    ...
    strExt = ".pdf"
    ...

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Vediamo la funzione. Dipende da come quella variabile sia "controllata" nello script.

    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    codice:
    <%
    cartella = "nomecartella"
    Dim objFso, objFolder, objFiles
    Dim strFolder, strFile, strPath, strExt
    
    strPath = "" & cartella & "" 
    strExt = ".pdf"
    
    Set objFso = Server.createObject("Scripting.FileSystemObject") 
    Set objFolder = objFso.GetFolder(Server.MapPath(strPath)) 
    Set objFiles = objFolder.Files 
    
    set custRs = Server.CreateObject("ADODB.Recordset")
    custRs.Fields.Append "nome", 200, 300 ' adVarChar
    custRs.Fields.Append "data", 7 ' Date
    custRs.Open
    If objFiles.count > 0 then
    For Each strFile in objFiles
    
    custRs.AddNew
    custRs("nome") = strFile.name
    custRs("data") = strFile.DateCreated
    
    next
    
    custRs.Sort = "data Desc"
    
    custRs.movefirst
     
    Do until custRs.eof
     
    	if Right(lcase(custRs("nome")), Len(strExt)) = lcase(strExt) then 
    
        %>
    		<%=custRs("nome")%>
    	
    	<%  
    end if
    
       custRs.movenext
    loop
    
    %>

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    if Right(lcase(custRs("nome")), 3) = "pdf" or _
      Right(lcase(custRs("nome")), 3) = "doc" or _
      Right(lcase(custRs("nome")), 3) = "xls" then
      .....................
      .....................
    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2005
    Messaggi
    2,630
    grazie 1000

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.