Search Persits Software Knowledge Base


Article PS01110872

Hiding the . and .. directories in the DirectoryListing.asp sample script

Problem Description

The code sample DirectoryListing.asp which comes with AspUpload displays all folders and files in a given directory, including the links to the current directory (".") and parent directory (".."). This article explains how to hide the "." and ".." links so that a user could not navigate to the parent directory.


The following simple modifications need to be made to the file DirectoryListing.asp:

1. A condition statement should be inserted at the beginning of the main For-Each loop, as follows:

<% For Each Item in Dir %>

<% If Item.FileName <> "." and Item.FileName <> ".." Then %>

<% If Item.IsSubdirectory Then %>

2. A matching End If statement should be added at the bottom of the main loop, as follows:


<% End If %>

<% Next %>

Created: 2/8/2002 5:21:34 AM
Last Modified: 2/9/2002 3:27:34 PM

Copyright © Persits Software, Inc. 1998 - 2023
For technical support, write to