473,586 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list documents in a html table

Ken
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken
Jul 19 '05 #1
5 2755
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set oFiles = oFSO.GetFolder( "D:\PathOnServe r").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Na me%></td>
<td><%=oFile.Da teLastModified% ></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfr eeingr.com> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in a html table. Is there any way to generate the table with the documents listed instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken

Jul 19 '05 #2
Ken,

How about you save them in a database table.

Quewry your table and loop through each record
interweaving it with HTML and that would save you
changing your HTML code each time.
-----Original Message-----
I currently have a set of documents in a directory that i need to list in ahtml table. Is there any way to generate the table with the documents listedinstead of having to update the table manually everytime a new document isadded to the list.

Thanks
Ken
.

Jul 19 '05 #3
Ken
Thanks for the response.
This is just what I need. One more question. How can I create a link to the
files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:um******** *****@TK2MSFTNG P11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for the moment that the directory is on the IIS server. There are at least two options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set oFiles = oFSO.GetFolder( "D:\PathOnServe r").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Na me%></td>
<td><%=oFile.Da teLastModified% ></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfr eeingr.com> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new document

is added to the list.

Thanks
Ken


Jul 19 '05 #4
Generate the HTML that would provide a link. What do you want the resultant
HTML to look like? You'd want it to look like:
<td><A href="filex.doc ">filex.doc </a></td>

right? What is filex.doc? It's the current .Name property of the current
file while looping. So, to get that resultant HTML, you'd do:
'''other code
For Each oFile in oFiles
%>
<tr>
<td><A href="<%=oFile. Name%>"><%=oFil e.Name%></A></td>
<td><%=oFile.Da teLastModified% ></td>
</tr>
<%
Next
'''other code
Ray at work


"Ken" <kl*****@spamfr eeingr.com> wrote in message
news:uq******** ******@TK2MSFTN GP11.phx.gbl...
Thanks for the response.
This is just what I need. One more question. How can I create a link to the files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:um******** *****@TK2MSFTNG P11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least

two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.).

If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set oFiles = oFSO.GetFolder( "D:\PathOnServe r").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Na me%></td>
<td><%=oFile.Da teLastModified% ></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous access on your site (default).

Ray at work

"Ken" <kl*****@spamfr eeingr.com> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
I currently have a set of documents in a directory that i need to list

in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new

document is added to the list.

Thanks
Ken



Jul 19 '05 #5
On Tue, 22 Jul 2003 10:36:25 -0500, "Ken" <kl*****@spamfr eeingr.com>
wrote:
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.


Here's how we serve up files from a folder dynamically:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("S cripting.FileSy stemObject")
Set f = fs.GetFolder(se rver.mappath(di rtowalk))
Set fc = f.Files
response.write "<UL>"
For Each FileName in fc
StringLength = Len(FileName.na me)
StringLength = StringLength - 4
TemporaryName = Left(FileName.n ame,StringLengt h)
DisplayName = Replace(Tempora ryName,"_"," ")
response.write "<LI><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A><br>"
Next
response.write "</UL>"
%>

No table, just a list of files without extensions, automatically
linked to the files. We normally publish in PDF format, try this link
for the end result:

http://manager.naplesgov.com/updates/2003.asp

I use this snippet quite a few places to serve up a list of documents
dynamically, but don't blame me for the code. I picked it up quite a
while ago and I'd credit the original author if I knew who it was.
Though I'm the one to blame for making the display pretty. :)

The code displays the file name, replacing underscores with spaces.
So we put the files to be served in the folder like this:

This_is_a_file. pdf
Here_is_Another .pdf

And so on. Adding table code into the loop isn't hard, something
like:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("S cripting.FileSy stemObject")
Set f = fs.GetFolder(se rver.mappath(di rtowalk))
Set fc = f.Files
response.write "<TABLE CELLPADDING=2>"
For Each FileName in fc
StringLength = Len(FileName.na me)
StringLength = StringLength - 4
TemporaryName = Left(FileName.n ame,StringLengt h)
DisplayName = Replace(Tempora ryName,"_"," ")
response.write "<TR><TD><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A></TD></TR>"
Next
response.write "</TABLE>"
%>

Change the dirtowalk variable to whatever directory you'll be using as
well as the appropriate HREF path.

Hope it helps.

Jeff
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2434
by: Neil Varshneya | last post by:
Hi, I'm looking for an html code list that contains all html codes and their effects. If all of you smart people who read this article know where such a list is please post a follow-up message to this article. Any possible information partaining to my requests is very highly appreciated!!! Thank you in advance!!!(I'd be glad to hear from...
9
1609
by: Stephen Tyndall | last post by:
This is the updated version of the resources list posted last month. Updates: -Now application-neutral. The old list had video game-related programming books. -Required reading section added. -Separate section about the Thinking in C++ books now. -C++ Programming in Easy Steps was removed from the beginners' list. Not a bad book, but...
33
2809
by: abs | last post by:
Hi all. My list: <ul> <li id="a" onclick="show(this)">Aaaaaaaa</li> <li id="b" onclick="show(this)">Bbbbbbbb</li> <li id="c" onclick="show(this)">Cccccccc <ul> <li id="d" onclick="show(this)">111111</li>
12
4159
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word" Response.AddHeader("content-disposition", "inline; filename=BP_CaseStatus.doc") Now all I should have to do is create the page just like I would if I were...
69
16814
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000); ------------------------------------------------------------ Here is the HTML that I'm producing:
9
1284
by: Thomas Ploch | last post by:
Hello fellow pythonists, I have a question concerning posting code on this list. I want to post source code of a module, which is a homework for university (yes yes, I know, please read on...). It is a web crawler (which I will *never* let out into the wide world) which uses regular expressions (and yes, I know, thats not good, too). I...
2
6222
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a Table/Query. Or it could be a value list, a static list of data. But what if your information is not held in a table, and it is not a static list. Examples...
0
30199
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is a comprehensive list of all autostart locations for Windows OSes: NOTE : These are some abbreviations used in this list. Please note them...
7
5760
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.