Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

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
0
toros
Asked:
toros
1 Solution
 
mcixCommented:
With ASP you can use the File System Object.  I think I have some code that does that sort of thing...
0
 
raooolCommented:
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.
0
 
MasseyMCommented:
Here is a program that I wrote in ASP to list all the graphics in a directory and then send them to a script so I could see how they look as backgrounds:

GO2.ASP
--------------------------------------------------------
<html>
<head><title></title></head>
<body>

<STYLE>
TH      {
      color:Black;
      background:Silver;
      }

</STYLE>

<% SG = Request.QueryString("SG") %>

<%

Set fs = CreateObject("Scripting.FileSystemObject")       'Create the FileSystemObject
If Request.QueryString("F") = "" then
      Response.Write "<FORM METHOD=GET>"
      Response.Write "Which Directory should I start in?&nbsp;<INPUT NAME=""F"" VALUE="":\"">"
      Response.Write "<INPUT TYPE=SUBMIT VALUE=""Browse Directory""><BR>"
      Response.Write "Show Graphics as Thumbnails? <INPUT TYPE=RADIO NAME=""SG"" VALUE=1> Yes | <INPUT TYPE=RADIO NAME=""SG"" VALUE=0> No"
      Response.Write "</FORM>"
Else
      Set fold = fs.GetFolder(Request.QueryString("F"))
Response.Write ("<TABLE WIDTH='100%'>")
Response.Write ("<TR><TD>")

 Response.Write ("      <TABLE BORDER WIDTH='100%'>")
 Response.Write ("            <TH ALIGN =LEFT><A STYLE=""text-align:left;"" HREF=/>Back</A></TH>")
 Response.Write ("                  <TABLE BORDER WIDTH='100%'>")
 Response.Write ("                        <TH ALIGN = CENTER>" & fold.Path & "</TH>")
 Response.Write ("                  </TABLE>")
 Response.Write ("      </TABLE>")
 Response.Write ("</TD></TR>")

response.Write "<TABLE WIDTH='100%'><TR><TD VALIGn=TOP>"
Response.Write "<TABLE WIDTH='100%'>"
 Set foldCol = fold.SubFolders                              'Create a SubFolders collection
 For Each Y in foldCol                                    'Iterate through it
  Response.Write "<TR>"                              
  Response.Write "<TD><IMG SRC='/GRAPHICS/Folder.Gif'><A HREF=go2.asp?F=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &Y.Name & "</A>"
  Response.Write "</TD>"
  Response.Write "</TR>"
 Next
  Response.Write "</TABLE>"

Response.Write "</TD><TD>"

response.Write "<TABLE WIDTH='100%'>"
 Set foldCol2 = fold.Files                              'Create a Files collection
 For Each Y in foldCol2
 Cur = Cur + 1                                    'Iterate through it
  If Cur >= 6  then Response.Write "<tr>"      
  Response.Write "<td WIDTH='20%'>"
If Right(Y.Path,3) = "gif" or Right(Y.Path,3) = "jpg" then
  If SG = "1" then
      Response.Write "<IMG WIDTH =50 HEIGHT=50  SRC=" & Y.Path &" ><BR>"
  End If
  Response.Write "<A HREF=ViewasBG.asp?G=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &Y.Name & "</A>"            'Print the files name
End If
  Response.Write "</td>"
  If Cur >= 5 then
      Response.Write "</tr>"
      Cur = 0
  End If
 Next                                                      
 Response.Write "</table>"
 For Each Y in foldCol                                    'Now lets iterate through the folder collection again
 Next
Response.Write "</TABLE>"
Response.Write "</TD></TR></TABLE>"
End If
%>


ViewasBG.ASP
----------------------------------------------------------
<% Graphic = Request.QueryString("G") %>
<% UT = Request.QueryString("UT") %>
<% UT = 1 %>
<% If UT = "1" then %>
<% ML=Request.QueryString("ML") %>
<!-- #Include Virtual="/Sample.Asp"-->
<% End If %>
<%
Set fs = CreateObject("Scripting.FileSystemObject")
%>

</BODY>


SAMPLE.ASP
----------------------------------------------------
anything you want.. I use all the colors so I can see how they look against the background..

0
 
torosAuthor Commented:
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></head>
<body>

<%
PRIVATE sub intoFold(newfold)

 set fold = fileSYSObj.GetFolder(newfold)                  
 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.FileSystemObject")
  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.FileSystemObject")       
intoFold("d:\test")                                    
%>
</body>
</html>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now