Browser Sub-Directories

R

rn5a

A ListBox lists all the folders & files existing in a directory named
'MyDir' on the server. Assume that the ListBox lists 2 directories -
'Dir1' & 'Dir2' i.e. these 2 directories reside in the 'MyDir'
directory. Both 'Dir1' & 'Dir2' also house sub-directories & files.
Assume that the sub-directory 'Dir1' has 3 directories & 3 files.

When a user comes to a ASPX page for the first time, the ListBox lists
all the directories & files existing in 'MyDir'. As expected, the
ListBox also lists the 2 sub-directories 'Dir1' & 'Dir2'.

What I want is when a user selects, say, 'Dir1' from the ListBox &
clicks a Button, then the ListBox should now list the directories &
files existing in 'Dir1' so that the user can view all the directories
& files residing in 'Dir1'.

How do I do this?
 
G

Gaurav Vaish \(www.Edujini-Labs.com\)

What's the problem?

Handle SelectedIndexChanged event of the listbox

Simultaneously, have a hidden field, if need be, whose value would point to
the parent directory whose listing is to be displayed in the listbox.

For example:

hiddenField.Value = "/"; // (/ is the root of the directory -- like MyDir)
listBox.Items.Add(..); // Add all the files and folders

when the form is submitted, do the following:

1. hiddenField.Value = hiddenField.Value + listBox.SelectedValue + "/"; (if
a folder has been selected)
Leave it unchanged if the file was selected

2. listBox.Items.Add(...);
This time, search for the files in the folder "MyDir" +
hiddenField.Value.Replace("/", "\\")

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Populate ListBox With Directories & Files 4
Access Denied 5
Range object causing Sort to fail 2
Un-nesting Files 2
Rename Folder 3
Need help to move directories... 12
Sort ListBox 4
File Listing 3

Top