Solved

asp file read...

Posted on 1999-01-25
4
175 Views
Last Modified: 2013-12-25
Can someone supply me with an asp page that will list all of the html files that reside in its directory in a clickable menu?  My books dont go into it very well.
0
Comment
Question by:jedimike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1859185
Sure, this is a small script that lists the "gif" and "jpg" files (by extension).  you can manipulate it for html pages though.

Index.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 ACTION=index.asp>"
      Response.Write "Which Directory should I start in?&nbsp;<INPUT NAME=""F"">"
      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 CHECKED> No"
      'Response.Write "<BR>Sample page to display: <INPUT NAME=""sample"" VALUE=""sample.asp"">"
      Response.Write "<BR>View Graphic on CAROS template: <INPUT NAME=""CAROS"" VALUE=""ViewOnCAROS"" TYPE=CHECKBOX>"
      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=" & Request.ServerVariables("HTTP_REFERER") & ">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=index.asp?F=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">&nbsp;" &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 & "&CAROS=" & Request("CAROS")
  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") %>

<% If Request.QueryString("CAROS") <> "" then %>
      <!-- #Include Virtual="/CRM/CAHeader.asp" -->
      <CENTER><FONT COLOR="RED" SIZE=+3>T E M P L A T E   V I E W</FONT><BR>
            <IMG SRC="<% =request.querystring("G") %>"><BR>
      <A HREF="javascript:history.back(1);">Back</A></CENTER>
      <!-- #Include Virtual="/CRM/CAFooter.asp" -->

<% Else %>
      <% ML=Request.QueryString("ML") %>

      <!-- #Include File="sample2.asp"-->
      <CENTER><A HREF="javascript:history.back(1);">Back</A></CENTER>
<% End If %>
</BODY>
0
 
LVL 2

Author Comment

by:jedimike
ID: 1859186
it must be a page where you load it and it lists all the .html files in the directory that it sits in.  Sorry Massey, but I cant use that.  
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 100 total points
ID: 1859187
Ok, check this one out...

<html>
<head><title></title></head>
<body>
<%
  Dim fso, f, f1, fc, s
  Set fso = CreateObject("Scripting.FileSystemObject")
      TheFile = Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))
      loc = InStrRev(TheFile,"\")
      TheFile = Left(TheFile,loc)
  Set f = fso.GetFolder(TheFile)
  Set fc = f.Files
  For Each f1 in fc
      if right(f1,5) = ".html" or right(f1,4) = ".htm" then
            s = s & "<A HREF='" & f1.name & "'>" & f1.name & "</A>"
            s = s &  "<BR>"
      End If
  Next
  ShowFileList = s

%>
<%
response.write ShowFileList
%>
</body>
</html>

0
 
LVL 2

Author Comment

by:jedimike
ID: 1859188
Now that's what Im looking for.....
Thank you....
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question