Monday, June 13, 2011

How to Create sitemap of a website


<%@ 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)

Dim subdirectoryEntries As String() = Directory.GetDirectories(strDir)

If Directory.Exists(strDir) Then
Try

Dim subdirectory As String
For Each subdirectory In subdirectoryEntries
rstText.Text += subdirectory & "<br>"
listFiles(subdirectory)
getDir(subdirectory)
Next subdirectory
Catch ex As Exception
strMsg.Text = "Error : " & ex.toString()
End Try
end if
end sub
Sub listFiles(strDir)
try

Dim fileEntries As String() = Directory.GetFiles(strDir)

Dim fileName As String
For Each fileName In fileEntries
rstFiles.text += fileName & "<br>"

Next fileName
Catch ex As Exception
strMsg.Text = "Error : " & ex.toString()
End Try

end sub
</script>
<html><head><title>Site Map</title></head><body>

<asp:label id="rstText" runat="server" Font-Names="Verdana" Font-Size="12px"/>
<p>
<asp:label id="rstFiles" runat="server" Font-Names="Verdana" Font-Size="12px"/>
<p>
<asp:label id="strMsg" runat="server" Font-Names="Verdana" Font-Size="12px"/>

</body></html>

No comments:

Post a Comment