Foros del Web » Programando para Internet » ASP Clásico »

[SOLUCIONADO]Borrar Archivos[SOLUCIONADO]

Estas en el tema de [SOLUCIONADO]Borrar Archivos[SOLUCIONADO] en el foro de ASP Clásico en Foros del Web. Muy wenas, una vez más aqui estamos Tengo la siguiente duda, tengo un código que me muestra los archivos de una carpeta del servidor y ...
  #1 (permalink)  
Antiguo 22/06/2004, 05:36
Avatar de angel_dope  
Fecha de Ingreso: noviembre-2002
Ubicación: Valencia
Mensajes: 737
Antigüedad: 21 años, 6 meses
Puntos: 8
[SOLUCIONADO]Borrar Archivos[SOLUCIONADO]

Muy wenas, una vez más aqui estamos Tengo la siguiente duda, tengo un código que me muestra los archivos de una carpeta del servidor y que permite desplazarse por las subcarpetas, abrir documentos, etc, y lo q quiero es poder borrar los archivos, es decir, poner alado de cada documento un boton, enlace o lo q sea, q me permita borrar ese archivo concretamente.

Os dejo el código que utilizo por si sirve para algo, solo pongo la parte que busca los archivos y los muestros, lo de las carpetas no lo pongo, no creo q haga falta

Código PHP:
<%
'kc_fsoFiles
'
Purpose:
'    1.    To create a recordset using the FSO object and ADODB
'    
2.    Allows you to exclude files from the recordset if needed
'Use:
'    
1.    Call the function when you're ready to open the recordset
'        
and output it onto the page.
'    example:
'        
Dim rsFSOstrPath
'        strPath = Server.MapPath("\PlayGround\FSO\Stuff\")
'        
Set rsFSO kc_fsoFiles(strPath"_")
'        The "_" will exclude all files beginning with 
'        
an underscore 
Function kc_fsoFiles(theFolderExclude)
Dim rsFSOobjFSOobjFolderFile
Const adInteger 3
Const adDate 7
Const adVarChar 200
    
'create an ADODB.Recordset and call it rsFSO
    Set rsFSO = Server.CreateObject("ADODB.Recordset")
    '
Open the FSO object
    Set objFSO 
Server.CreateObject("Scripting.FileSystemObject")
        
'go get the folder to output it's contents
        Set objFolder 
objFSO.GetFolder(theFolder)
    
'Now get rid of the objFSO since we're done with it.
    
Set objFSO Nothing
        
'create the various rows of the recordset
        rsFSO.Fields.Append "Name", adVarChar, 200
        rsFSO.Fields.Append "Type", adVarChar, 200
        rsFSO.Fields.Append "DateCreated", adDate
        rsFSO.Fields.Append "DateLastAccessed", adDate
        rsFSO.Fields.Append "DateLastModified", adDate
        rsFSO.Fields.Append "Size", adInteger
        rsFSO.Fields.Append "TotalFileCount", adInteger
        rsFSO.Open
        
        '
Now let's find all the files in the folder
        For Each File In objFolder.Files
            '
hide any file that begins with the character to exclude
            
If (Left(File.Name3)) <> Exclude Then 
                rsFSO
.AddNew
                rsFSO
("Name") = File.Name
                rsFSO
("Type") = File.Type
                rsFSO
("DateCreated") = File.DateCreated
                rsFSO
("DateLastAccessed") = File.DateLastAccessed
                rsFSO
("DateLastModified") = File.DateLastModified
                rsFSO
("Size") = File.Size
                rsFSO
.Update
            End 
If
        
Next
        
'And finally, let'declare how we want the files 
        
'sorted on the page. In this example, we are sorting 
        '
by File Type in  descending order,
        
'then by Name in an ascending order.
        rsFSO.Sort = "Name Asc, Size ASC "

    '
Now get out of the objFolder since we're done with it.
    Set objFolder = Nothing

    '
now make sure we are at the beginning of the recordset
    
'not necessarily needed, but let'do it just to be sure.
if 
not rsfso.eof and not rsfso.bof then
    rsFSO
.MoveFirst()
End if
    
Set kc_fsoFiles rsFSO
End 
Function

'Now let's call the function and open the recordset on the page

'the folder we will be displaying
Dim strFolder : strFolder = Server.MapPath("..\..\comun\" & Request.QueryString("Path"))


'
the actual recordset we will be creating with the kc_fsoFiles function
Dim rsFSO 'now let's call the function and open the recordset
'we will exclude all files beginning with a "_"
Set rsFSO = kc_fsoFiles(strFolder, "-")

'
now we'll create a loop and start displaying the folder
'
contents with our recordsetOf coursethis is just a
'simple example and not very well formatted, i.e., not in
'
a tablebut it gets the point across on how you can
'ouput the recordset on the page.
%>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="18">
  <tr valign="top"> 
    <td colspan="2" height="12"><font face="Arial, Helvetica, sans-serif"><b>Documentos 
      disponibles en la carpeta activa: <%=Request.Querystring("Path")%></b></font> 
      <div align="right"><b><a href="<%=enlace%>"></a></b></div>
    </td>
    <%enlace = "nuevo_doc.asp?path=" &(Request.Querystring("path"))%>
    <td width="5%" height="12"> 
      <div align="right"> 
        <p><font face="Arial, Helvetica, sans-serif"><b><a href="javascript:window.history.back(1)"><img src="arriba.jpg" border="0"></a></b></font></p>
      </div>
    </td>
  </tr>
  <tr valign="top"> 
    <td width="70%" height="12">&nbsp;</td>
    <td width="25%" height="12">&nbsp;</td>
    <td width="5%" height="12">&nbsp;</td>
  </tr>
  <tr valign="top">
    <td width="70%" height="12">&nbsp;</td>
    <td width="25%" height="12"><b><a href="<%=enlace%>"><font face="Arial, Helvetica, sans-serif" color="#FF9900" size="2">Subir 
      Archivo a la carpeta activa</font></a></b></td>
    <td width="5%" height="12">&nbsp;</td>
  </tr>
</table>
<br>
<table width="100%" border="1" align="left" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="42%"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif"><b>Nombre</b></font></div>
    </td>
    <td width="28%"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif"><b>Tipo de 
        Archivo</b></font></div>
    </td>
    <td width="18%"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif"><b> &Uacute;ltima 
        Modificaci&oacute;n </b></font></div>
    </td>
    <td width="12%"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif"><b>Tama&ntilde;o</b></font></div>
    </td>
  </tr>
  <%
While Not rsFSO.EOF
enlace = "../../comun/"& Request.QueryString("Path") &"/"& rsFSO("Name").Value
%>
  <tr> 
    <td width="42%" height="15"> 
      <div align="left">
        <%
Cadena2 = rsFSO("Name").Value
Primer_Caracter2 = Left(Cadena2,1)
Resto_Cadena2 = Right(Cadena2,len(Cadena2)-1)
Cadena_Convertida2 = UCase(Primer_Caracter2) & LCase(Resto_Cadena2)


%>
        <font face="Arial, Helvetica, sans-serif" size="2"><a href="<%=enlace%>"><%= Cadena_Convertida2 %> </a></font></div>
    </td>
    <td width="28%" height="15"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><%= rsFSO("Type").Value %></font></div>
    </td>
    <td width="18%" height="15"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><%= rsFSO("DateLastModified").Value %></font></div>
    </td>
    <td width="12%" height="15"> 
      <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><%= rsFSO("Size").Value/1000 &" Kb" %></font></div>
    </td>
  </tr>
  <%
    '
and let's move to the next record
    rsFSO.MoveNext()
Wend
%>
</table>
<p> 
  <%
'
finallyclose out the recordset
rsFSO
.close()
Set rsFSO Nothing

%> 
Muchas gracias por adelantado, salu2
__________________
Vayamos por Partes :: Jack el Destripador

Última edición por angel_dope; 23/06/2004 a las 03:39 Razón: SOLUCINADO
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:14.