Files in folder.

This is a discussion on "Files in folder." within the Classic ASP section. This forum, and the thread "Files in folder. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 24th, 2003, 02:48
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Files in folder.

I need a script and I'm totally useless writing new things. Is i ask really kindly i hope that someone can help me. This is what i need. I need the script to look in a folder for img,pdf,or doc files and if there are files in the folder it takes them posts them on the web as a link with the newest file at the top. It would be nice if there was a way to restrict how many files it would list and what files i wanted it to list.

But it needs to post the files as a table which looks like this
Date uploaded File name Format Size
file1
file2
file3

Is there anyone that can help me with this, the idea is that I put the scriptin a asp page and build the sorrounding look and feel around it. I'd just like to THANK YOU THANK YOU right now for anyone that feels that this is somthing they could help me with,......

Cheers

  #2 (permalink)  
Old Sep 24th, 2003, 08:13
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
http://asp101.com/samples/dir_list_sort.asp

HTH
Smokie
  #3 (permalink)  
Old Sep 24th, 2003, 22:26
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thats great I have gotten it to work. I have 2 questions. How do i get this rstFiles.Fields("date").Value = objItem.DateCreated to only display a date and not the date and time.

And Q2 how do I get this rstFiles.Fields("size").Value = objItem.Size to display it all in Kb and not bytes. This is how I yuse it today

<td class="text"><%= rstFiles.Fields("date").Value %></td>
<td class="text"><%= rstFiles.Fields("size").Value %></td>

Sorry for the dumb questions...
Cheers
  #4 (permalink)  
Old Sep 25th, 2003, 08:30
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
FormatDateTime(rstFiles.Fields("date").Value,2)

Cint(rstFiles.Fields("size").Value / 1024)
  #5 (permalink)  
Old Sep 26th, 2003, 00:06
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you Thank you thank you it's all working great and everyone is happy. I can't thank you enough for what you have done for me. I have learnt so much and the help that you get here in the best ever. I'll be coming back.... Just to bad that I'm in Australia and it seems that the rest of you are on another timezone as I have to wait about one day to get a answer.

Anyway. Thanks again...:-)
  #6 (permalink)  
Old Sep 26th, 2003, 00:19
New Member
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Just so you can see this is the script as I use it today. I actually call this file from a include file inside one of my pages.

<%
Dim strPath
Dim objFSO
Dim objFolder
Dim objItem
Dim rstFiles
Const adVarChar = 200
Const adInteger = 3
Const adDate = 7

' NOTE: As currently implemented, this needs to end with the /
strPath = "./docs/2003/announcements/"

' Create our FSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

' Get a handle on our folder
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))

%>

<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr>
<td class="form_head">Date</td>
<td class="form_head">File</td>
<td class="form_head">Format</td>
<td class="form_head">Size</td>
</tr>
<%


Set rstFiles = Server.CreateObject("ADODB.Recordset")
rstFiles.Fields.Append "name", adVarChar, 255
rstFiles.Fields.Append "size", adInteger
rstFiles.Fields.Append "date", adDate
rstFiles.Fields.Append "type", adVarChar, 255
rstFiles.Open

For Each objItem In objFolder.Files
rstFiles.AddNew
rstFiles.Fields("name").Value = objItem.Name
rstFiles.Fields("size").Value = objItem.Size
rstFiles.Fields("date").Value = objItem.DateLastModified


If Len(objItem.Type) > 17 Then
rstFiles.Fields("type").Value = Left(objItem.Type, 14) & ""
Else
rstFiles.Fields("type").Value = objItem.Type
End If
Next 'objItem

Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing


rstFiles.Sort = "date DESC"

rstFiles.MoveFirst

Do While Not rstFiles.EOF

%>
<tr>
<td class="text"><%= FormatDateTime(rstFiles.Fields("date").Value,2) %></td>
<td class="text">" target="_blank"><%= rstFiles.Fields("name").Value %></td>
<td class="text" align="left"><%= rstFiles.Fields("type").Value %></td>
<td class="text" align="right"><%= Cint(rstFiles.Fields("size").Value / 1024) %> kb</td>

</tr>
<%
rstFiles.MoveNext
Loop

' Close the ADO Recordset object
rstFiles.Close
Set rstFiles = Nothing
%>
  #7 (permalink)  
Old Sep 26th, 2003, 11:24
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
glad to have been able to help!!!

If you like this forum, tell your friends!!



Smokie
Closed Thread

Tags
files, folder

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing files in a folder ismilelots PHP Forum 5 Feb 15th, 2007 18:49
Folder Permissions djanim8 Classic ASP 0 Nov 29th, 2006 15:03
301 folder direct help marcogolfo Web Page Design 3 Nov 14th, 2006 21:54
IFrame to FTP folder Webforumz Staff Web Page Design 17 Oct 28th, 2004 12:37


All times are GMT. The time now is 23:54.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43