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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why doesnt this work

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
Hi:


objStartFolder = "d:\"
LogFile = "file list.txt"
Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)

Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
objLogFile.Write objFolder.Path & "\" & objFile.Name
objLogFile.Writeline
Next


ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
config ="config"
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
'objLogFile.Write Subfolder.name & "\" & objFile.Name
'objLogFile.Writeline

arrmemfiles = array(objfile.name)
for i = 0 to ubound(arrmemfiles)
b = filter(arrmemfiles, "web.config")
for each x in b
'this should echo when it finds web.config
wscript.echo x


next
next
next

ShowSubFolders Subfolder
next
End Sub

objLogFile.Close

I have the words web.config in the folder but it doesnt seem to seee it? Is it that the array is not strings?
 
There seems to be some confusion as to what the 'array' function is returning. In your loop you are overwriting arrmemfiles with the current file name each time through the loop. If you want to keep an array of file names there are a number of ways to do it, you might try something like this:

Code:
dim arrmemfiles()
i = 0
for each file in colfiles
  redim preserve arrmemfiles(i)
  arrmemfiles(i) = file.name
  i = i + 1
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top