Hello need help maybe some one can even offer me a better way of doing this. I have an application that i need to get all files from a give folder and its subfolder.
In my main page I call the getsubfolder(folder,file) function
I pass it a folder path that was enterd in form and html form (will spare you the html code for that) and i pass a empty value for the file.
the issue i am having is that if a subfolder has files and no subfolders i do not enter into my for loop and call the getsubfolder() function and pass the tmp to append the new list of files to tmp variable. the function will just drop back a loop and move to the next folder in the folder array for that for loop. (confusing i know I slept on this one). My question for you is how do it get that last string of filenames to be appended to the tmp variable if there is no subfolders to activare the recall to pass it through?
Code:Function getsubfolder(folder,file) //first i call the getfile() function to get a list of the file(s) in this folder getfiles(folder) //then i create a tmp variable to pass the file string throught getsubfolder function so that at the end I have a string of all my file names form all folders and sub folders to split on the : and place in a table on the main page. dim tmp tmp = tmp + file tmp = tmp //get the sub folders dim fs,fo,x set fs=Server.CreateObject("Scripting.FileSystemObject") set fo=fs.GetFolder(folder for each x in fo.SubFolders // call this function on its self to get the sub folders and files pass tmp to //keep track of prev file names. getsubfolder(folder,tmp) next set fo=nothing set fs=nothing getsubfolder = tmp end function function getfile(folder) dim fs,fo,x,tmp,filename set fs=Server.CreateObject("Scripting.FileSystemObject") sfo=fs.GetFolder(folder) for each x in fo.files 'Print the name of all files in the test folder filename = x.Name & ":" tmp = tmp + filename next tmp = tmp set fo=nothing set fs=nothing getfile = tmp end Function



Reply With Quote
Bookmarks