|
 |
asp_web_howto thread: Selection list of file names
Message #1 by "Jim Andrews" <jim@t...> on Thu, 17 Jan 2002 20:39:05
|
|
I need to present the user with a drop-down option selection list
containing the names of files in a given folder on the domain server. Can
someone help me code this?
Message #2 by Oleg Kapeljushnik <c-oleg.kapeljushnik@w...> on Thu, 17 Jan 2002 15:44:52 -0500
|
|
I have this function
Hope this is what you need.
Function GetDirectoryList(FilenameDefault)
Dim objFSO,objFolder,objFile
Dim str
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FILES_PATH)
str = ""
For Each objFile in objFolder.Files
if UCase(Right(objFile.Name,3)) = "M04" then
str = str & "<option value=""" & objFile.Name & """"
if FilenameDefault=objFile.Name then str = str & " selected "
str = str & ">" & objFile.Name & "</option>"
End If
Next
Set objFSO = nothing
if str = "" then
GetDirectoryList = "<option>None</option>"
Else
GetDirectoryList = str
End If
End Function
Oleg
-----Original Message-----
From: Jim Andrews [mailto:jim@t...]
Sent: January 17, 2002 3:39 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Selection list of file names
I need to present the user with a drop-down option selection list
containing the names of files in a given folder on the domain server. Can
someone help me code this?
$subst('Email.Unsub').
Message #3 by "Drew, Ron" <RDrew@B...> on Thu, 17 Jan 2002 16:04:57 -0500
|
|
FSO...if you do not know the path but know one of the files, do a
MapPath first and use it
filePath =3D Server.MapPath("blahblah.asp")...the example does not use
the
MapPath
<%
'Create the FileSystemObject object
Dim objFSO
Set objFSO =3D Server.CreateObject("Scripting.FileSystemObject")
'Obtain an folder object instance for a particular directory
Dim objFolder
Set objFolder =3D objFSO.GetFolder("C:\wwwroot\Blah\Blah\")
'Use a For Each ... Next loop to display the files
Dim objFile
For Each objFile in objFolder.Files
'Print out the name
Response.Write objFile.Path & "<BR>"
Next
%>
-----Original Message-----
From: Jim Andrews [mailto:jim@t...]
Sent: Thursday, January 17, 2002 3:39 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Selection list of file names
I need to present the user with a drop-down option selection list
containing the names of files in a given folder on the domain server.
Can
someone help me code this?
$subst('Email.Unsub').
|
|
 |