Read a directory and next making an action.

M

McGrull

Sorry for my question, but I'm really a newbie on ASP.

I need to make a simple page (for IIS 5.0 and up, but even for 2000
Professional IIS) that read and display the files contained in a
specified directory and next, clicking on one of them, calling and
making an action with an another ASP page. For example:

http://server/list.asp

Listing Y:\REPOSITORY

ONE.TXT
TWO.TXT


If I clic on ONE.TXT I need to call

http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT

Thank you in advance, and sorry for the dumb question.
 
R

Roland Hall

in message
: Sorry for my question, but I'm really a newbie on ASP.
:
: I need to make a simple page (for IIS 5.0 and up, but even for 2000
: Professional IIS) that read and display the files contained in a
: specified directory and next, clicking on one of them, calling and
: making an action with an another ASP page. For example:
:
: http://server/list.asp
:
: Listing Y:\REPOSITORY
:
: ONE.TXT
: TWO.TXT
:
:
: If I clic on ONE.TXT I need to call
:
: http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT

It's not a dumb question but why would you want to pass the physical path to
the file?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Roland Hall

in message : "McGrull" wrote in message
: :: Sorry for my question, but I'm really a newbie on ASP.
::
:: I need to make a simple page (for IIS 5.0 and up, but even for 2000
:: Professional IIS) that read and display the files contained in a
:: specified directory and next, clicking on one of them, calling and
:: making an action with an another ASP page. For example:
::
:: http://server/list.asp
::
:: Listing Y:\REPOSITORY
::
:: ONE.TXT
:: TWO.TXT
::
::
:: If I clic on ONE.TXT I need to call
::
:: http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT
:
: It's not a dumb question but why would you want to pass the physical path
to
: the file?

Here is a way to do it without passing the file path/name on the URL.
http://kiddanger.com/lab/geturl6.asp

There's a link on the page to view the source.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

McGrull

Thanks for your reply.

The application, that is third part, need the real path of the file
with the file for call argument . I try to call only the file, but
doesn't do the correct stuff.
 
M

McGrull

Thank you for all. Google and a bit of luck, help me..

I discovered that do the stuff i need. I post it for anyone need the
same..

<html>
<head>
<title></title>
</head><body>
<%
dirtowalk="/dirtoview/"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
For Each whatever in fc
response.write "<A HREF=http://server/make.asp?function="
response.write whatever.name
response.write ">"
response.write whatever.name
response.write "</A><br>"
Next
%>
</body>
</html>
 
R

Roland Hall

in message

: The application, that is third part, need the real path of the file
: with the file for call argument . I try to call only the file, but
: doesn't do the correct stuff.

you already know your virtual path so...

dim virPath, strPath
virPath = "/myfiles"
strPath = Server.MapPath("/myfiles")
Just prepend it: strPath & "/" & filename.ext


--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Roland Hall

in message
: Thank you for all. Google and a bit of luck, help me..
:
: I discovered that do the stuff i need. I post it for anyone need the
: same..
:
: <html>
: <head>
: <title></title>
: </head><body>
: <%
: dirtowalk="/dirtoview/"
: Set fs = Server.CreateObject("Scripting.FileSystemObject")
: Set f = fs.GetFolder(server.mappath(dirtowalk))
: Set fc = f.Files
: For Each whatever in fc
: response.write "<A HREF=http://server/make.asp?function="
: response.write whatever.name
: response.write ">"
: response.write whatever.name
: response.write "</A><br>"
: Next
: %>
: </body>
: </html>

My app is distinctly different as my URL never changes and nobody can use
the URL to pass a filename.
Glad you found something you can use.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

McGrull

Ok, and if are more files, and i want to array the listing in multiple
pages, linkable to view the page in my interest, how i can do that?
 
R

Roland Hall

in message
: Ok, and if are more files, and i want to array the listing in multiple
: pages, linkable to view the page in my interest, how i can do that?

If you're wanting to use the array on multiple pages then you could put your
array in a session variable but copy it to a local variable when you use it.

' get files, put into array
session("arrFiles") = arrFiles

' grab array from session when you want to use it.
dim arrFiles
arrFiles = session("arrFiles")

If you had your files in an array and you had 30 and wanted 10 on each page,
this is one way:

pages: list1, list2, list3

dim i, j, arrList1(), arrList2(), arrList3()
redim arrList1(9) : redim arrList2(9) : redim arrList3(9)
j = 0
for i = 0 to ubound(arrFiles) step 3
arrList1(j) = arrFiles(i)
arrList2(j) = arrFiles(i + 1)
arrList3(j) = arrFiles(i + 2)
j = j + 1
next
erase arrList
if session("assList1") <> "" then
session("arrList1") = arrList1
end if
session("arrList2") = arrList2
session("arrList3") = arrList3

....then on each page:

list1.asp
dim arrList, i
arrList = session("arrList1")
for i = 0 to ubound(arrList)
Response.Write "<a href=""" & arrList & """>" & arrList & "</a><br />"
next

list2.asp
....
list3.asp
....

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top