Why I can not list the virtual directory?

G

Guest

I basically use the following code to display the directory and file names in
the WWWROOT, but can not show the virtual directory.
----
Dim path As String = Server.MapPath(x)
Dim di As DirectoryInfo = New DirectoryInfo(path)
Listing.DataSource = di.GetFileSystemInfos()
Listing.DataBind()
----
Anyone can help me about how to list the virtual directory.

Thanks

David
 
B

Brock Allen

Dim path As String = Server.MapPath("~") ' or "/" if you want the site root
Listing.DataSource = Directory.GetDirectories(path)
Listing.DataBind()
 
G

gabe garza

A Virtual Directory is a name not a physical location. The physical location
of your Virtual Directory can be anywhere on your hard drive. So the
physical location of your Virtual Directory isn't always
c:\inetpub\wwwroot\virtualdirectoryname

If you need to know the physical directories of all your IIS Virtual
Directories, look at the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual
Roots
 
G

Guest

In
Dim path As String = Server.MapPath(x),
the x is relative path root. It works for real directory path within wwwroot.

David
 
G

Guest

Thank you both of you.
I just created the virtual directory from IIS. If I set the property of
directory browsing, I can directly access to the directory virtually and get
anything I want from IE without my form based authentication. Now I try to
access it programatically without that setting and list the directory tree.
It works for others (not virtual one).

David
 

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

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,100
Latest member
MelodeeFaj
Top