Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 help: problem with showing contents of a dir
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 24 July 2001 :  17:49:16  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
I need help with the following code. I use it to list the files in a directory. How can I prevent specific files (for example index.asp etc.) from being listed?
Thanks in advance for any help!


<%
folder = "/"
If Left(server.mappath("."),1) = "/" Then
strslash = "/"
Else
strslash = "\"
End If
servername = Request.Servervariables("server_name")
scriptpath = Request.Servervariables("script_name")
scriptpath = Mid(scriptpath,(Instrrev(scriptpath, "/")),1)
Dim filesobj, fileslist, fname, posnumright
dim f, dflm
Set filesobj = Server.CreateObject("scripting.filesystemobject")
Set fileslist = filesobj.GetFolder(server.mappath(".") & "/" & folder)
%>
<table border=0 width="98%" cellspacing=0 cellpadding=0 align=center>
<tr><td>
  
</td></tr>
<tr>
<td>
<table border=0 width="100%" cellspacing="1" cellpadding="4">
<tr>
<td align="center">File Name</td>
<td align="center">File Date</td>
<td align="center">File Size</td>
</tr>

<%
For each thing In fileslist.files
posnumright = instrrev(thing, strslash)
fname = right(thing,(len(thing)-posnumright))
Set f = filesobj.GetFile(thing)
fdlm = f.datelastmodified
If f.size > 1023 Then
fsize = CStr(CInt(f.size / 1024)) & "k"
Else
fsize = CStr(f.size) & " bytes"
End If
physicalpath = server.mappath(".")
%>
<tr>
<td>
<a href="http://<%=servername & scriptpath & "files/" & Server.HTMLEncode(fname) %>" title="<%=Server.HTMLEncode(fname) %>" target="_blank"><%=Server.HTMLEncode(fname)%></a>
</td>
<td>
<%=Server.HTMLEncode(fdlm)%></td>
<td>
<%= Server.HTMLEncode(fsize) %>
</td>
</tr>
<%
Set f = Nothing
Next
Set fileslist = Nothing
Set filesobj = Nothing
%>
</table>
</td></tr></table>



OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 04 August 2001 :  13:29:37  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
Already got the solution, thanks anyway.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07