Forum Moderators: open
'Get the file information
Set objFolder = objFSO.GetFolder("C:\Inetpub\wwwroot")
F = objFolder.Name
Set Folderwithin = objFSO.GetFolder(F)
Response.Write(Folderwithin.Name)
any suggestions?
Now it's printing everything in my wwwroot folder including other folders. Now I need it to read all the files within those folder and if there are folders read file in those as well.
SO I know it's just a matter of recursice loop somewhere but I have no idea how.
?
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objRootFolder = objFSO.GetFolder("C:\Inetpub\wwwroot")'Start the process on the root folder
ListFolder objRootFolderSub ListFolder( ByRef objFolder )'Display the folder name
Response.Write "Folder: " & objFolder.Name & "<br>"'Generate a list of the files in the current folder
Response.Write "--File list--<br>"
For Each objFile in objFolder.Files
fname_split = split(objFile.name,".")
if (fname_split(0) <> "dir") then
Response.Write sUP & objFile.name & "," & fname_split(0) & "<br>"
end if
Next
Response.Write "--File list--<br>"'Loop through each of the sub-folders
For Each objSubFolder in objFolder.SubFolders
ListFolder objSubFolder
NextEnd Sub
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = Application("Test")
objConn.Open
'Response.Write "<B>" & path & "</b><br>"
For Each File in objFolder.Files
'if the file extension is asp add to database
extsplit = split(File.name,".")
'This code runs for each file in a folder
displaysplit = split(path,"\")
For iLoop = LBound(displaysplit) to UBound(displaysplit)
if extsplit(1) = "asp" and (displaysplit(UBound(displaysplit))) <> "_notes" then
if iLoop = 3 then
Response.Write("<b>Display Name</b> - ")
For i = iLoop to UBound(displaysplit)
Response.Write " " & displaysplit(i)
PageName = displaysplit(i)
PageDescription = displaysplit(i)
Next
Response.Write " " & extsplit(0)
Response.Write (" <b>File Name</b> - ") & (File.Name) & "<BR>"
'strQuery = "INSERT INTO WebPages (PageName, Description, URL, FromDate) VALUES "
'strQuery = strQuery & "(""" & PageName & """, """ & PageDescription & """, """ & URL & """, #" & now() & "#);"
'on error resume next
'objConn.Execute strQuery
'if err<>0 then
'response.Write(err.description)
'else
'response.Write("Record was inserted!")
'end if
end if
end if
Next
Next
For Each Folder in objFolder.SubFolders
'This code runs for each subfolder
'Sub calls itself passing the path of the subfolder
Response.Write "<br>"
If left(Folder.Name,1) <> "_" Then
PrintFolderStructure(Folder.Path)
End If
Next
Set objFSO = Nothing
Set objConn = Nothing
End Sub
%>
I'm having trouble capturing the DisplayName and URL to put it in the database. Please help...
Shuvi