Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  File Objects: Read Directory
     [next Lesson]  File Objects: Read Disk Drive by Steven Harper

FileObjects Part 2 by Charles Carroll

The file object is in newer versions of VBScript. Here we use it to walk a directory and make links.

   filename=/learn/test/fileobjectslinks.asp

<Test Script Below>


<html><head>
<title>fileobjectslinks.asp</title>
</head><body>
<%
dirtowalk="/learn/test"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
For Each whatever in fc
    response.write "<A HREF='"
        response.write whatever.name
        response.write "'>"
        response.write whatever.name
        response.write "</A><br>"
Next
%>
</body></html>

Now we will display graphics in a directory.

   filename=/learn/test/fileobjectsgraphics.asp

<Test Script Below>


<html><head>
<title>fileobjectsgraphics.asp</title>
</head><body>
<%
dirtowalk="/images"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
For Each whatever in fc
    response.write "<IMG SRC='/images/"
        response.write whatever.name
        response.write "'>"
        response.write whatever.name & "<br>"
Next
%>
</body></html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.