Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A folders and files example help needed VBScript

Status
Not open for further replies.

spiderman0009

Technical User
Feb 19, 2002
23
CA
Hi I am very new to understanding this stuff in the second paragraph.
This is the most complex example that I have worked with. In the example below why did they create variables for f1, s when they are not used below in the code? Another question why do they use and declare a variable for the drivelet, why don't the just use "c:" in part filesys.GetDrive(drivelet) like this filesys.GetDrive(C:).
Last question why don't they define the variable fileobj before they use it in this code? &quot;For Each fileobj in rootfiles&quot; They use this... code. This code following says output all the fileobj variables that it finds. Correct? Could I use any other name for fileobj. and it would work?Correct? <%=fileobj.Name%> I am a little shakky on this stuff. I am still trying to understand the basic of VBScript


<%
Dim fileSys, drv, f1, s, rootdir, rootfiles, fileobj
Dim drivelet
drivelet = &quot;c:&quot;
Set filesys = CreateObject(&quot;Scripting.FileSystemObject&quot;)
' Get the Price object based on the drive letter
Set drv = filesys.GetDrive(drivelet)
' Get the Drive's root folder
Set rootdir = drv.RootFolder
'Get the files in the root folder
Set the rootfiles = rootdir.Files
'Loop through all the files and display them
For Each fileobj in rootfiles
%>
<%=fileobj.Name%> <p>

<%
Next
%>

Thank You Troy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top