toros
asked on
Contentspage
Can anyone tell me how I could make some kind of script that creates a page with a list of links based on the files in the same directory and their titles. I use WinNT and IIS4. So I guess it could be done both in JavaScript or ASP.
Tor Olaf
Tor Olaf
With ASP you can use the File System Object. I think I have some code that does that sort of thing...
Crude solution, but...
With IIs, set Directory Browsing Allowed for that directory (via management console). When a browser navigates to that directory without specifying a legal file name (and a default page does not exist) the server will return a linked list of filenames.
Presenting the <TITLE> would require some scripting.
With IIs, set Directory Browsing Allowed for that directory (via management console). When a browser navigates to that directory without specifying a legal file name (and a default page does not exist) the server will return a linked list of filenames.
Presenting the <TITLE> would require some scripting.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It gave me some ideas about how to solve it. If somebody's interrested, a solution that works follows :
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head><title></title></hea d>
<body>
<%
PRIVATE sub intoFold(newfold)
set fold = fileSYSObj.GetFolder(newfo ld)
Set foldCol2 = fold.Files
For Each Y in foldCol2
Response.Write "<A HREF='" & newfold & "\" & Y.Name & "'>"
ReadAllTextFile(newfold & "\" & Y.Name)
Next
end sub
Function ReadAllTextFile(FilePath)
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Set f = fso.OpenTextFile(FilePath, ForReading)
ReadAllTextFile = f.ReadAll
WriteTitle(ReadAllTextFile )
End Function
Function WriteTitle(Text)
Dim MyString,MyString2
MyString = Split(Text, "<TITLE>", -1, 1)
' MyString(0) contains Trash.
' MyString(1) contains the next splitstring.
MyString2 = Split(MyString(1),"</TITLE >",-1,1)
' MyString2(0) contains the title
Response.Write MyString2(0) & "</A><BR>"
End Function
Set fileSYSObj = CreateObject("Scripting.Fi leSystemOb ject")
intoFold("d:\test")
%>
</body>
</html>
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head><title></title></hea
<body>
<%
PRIVATE sub intoFold(newfold)
set fold = fileSYSObj.GetFolder(newfo
Set foldCol2 = fold.Files
For Each Y in foldCol2
Response.Write "<A HREF='" & newfold & "\" & Y.Name & "'>"
ReadAllTextFile(newfold & "\" & Y.Name)
Next
end sub
Function ReadAllTextFile(FilePath)
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.Fi
Set f = fso.OpenTextFile(FilePath,
ReadAllTextFile = f.ReadAll
WriteTitle(ReadAllTextFile
End Function
Function WriteTitle(Text)
Dim MyString,MyString2
MyString = Split(Text, "<TITLE>", -1, 1)
' MyString(0) contains Trash.
' MyString(1) contains the next splitstring.
MyString2 = Split(MyString(1),"</TITLE
' MyString2(0) contains the title
Response.Write MyString2(0) & "</A><BR>"
End Function
Set fileSYSObj = CreateObject("Scripting.Fi
intoFold("d:\test")
%>
</body>
</html>