<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
getDir(Server.MapPath("."))
end sub
Sub getDir(strDir As String)
Dim subdirectoryEntries As String() = Directory.GetDirectories(strDir)
If Directory.Exists(strDir) Then
Try
Dim subdirectory As String
For Each subdirectory In subdirectoryEntries
myDirectories.Text += subdirectory & "<br>"
listFiles(subdirectory)
getDir(subdirectory)
Next subdirectory
Catch ex As Exception
messaggi.Text = "Errore : " & ex.toString()
End Try
end if
end sub
Sub listFiles(strDir As String)
try
Dim fileEntries As String() = Directory.GetFiles(strDir)
Dim fileName As String
For Each fileName In fileEntries
myFiles.text += fileName & "<br>"
Next fileName
Catch ex As Exception
messaggi.Text = "Errore : " & ex.toString()
End Try
end sub
</script>
<html>
<body>
<asp:label id="myDirectories" runat="server" Font-Names="Verdana" Font-Size="12px"/>
<p><asp:label id="myFiles" runat="server" Font-Names="Verdana" Font-Size="12px"/>
<p><asp:label id="messaggi" runat="server" Font-Names="Verdana" Font-Size="12px"/>
</body></html>