By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Read a directory and next making an action.

P: n/a
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.

Jul 22 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"McGrull" wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
: 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
Jul 22 '05 #2

P: n/a
"Roland Hall" wrote in message news:O0**************@TK2MSFTNGP10.phx.gbl...
: "McGrull" wrote in message
: news:11*********************@z14g2000cwz.googlegro ups.com...
:: 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
Jul 22 '05 #3

P: n/a
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.

Jul 22 '05 #4

P: n/a
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>

Jul 22 '05 #5

P: n/a
"McGrull" wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

: 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
Jul 22 '05 #6

P: n/a
"McGrull" wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
: 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
Jul 22 '05 #7

P: n/a
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?

Jul 22 '05 #8

P: n/a
"McGrull" wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
: 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
Jul 22 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.