>Set oFSO=CreateObject("Scripting.FileSystemObject") >oFSO.GetFolder(Server.MapPath(".")) >You don't need to use the FileSystemObject to do this. There is a member of the ServerVariables collection in the Request object that stores the complete path and file name of the page you are on. Using this and a some string manipulation you can come up with the directory name of the current page being viewed:
' Get the full path for the page including the page name strFullPath = Request.ServerVariables("PATH_TRANSLATED") ' Determine the character position of the last backslash in the path intBackslashPos = InStrRev(strFullPath, "\") ' Strip off the file name and the last backslash strPathOnly = Mid(strFullPath, 1, intBackslashPos-1) ' Determine the character position of the last backslash in the path intBackslashPos = InStrRev(strPathOnly, "\") ' Now strip off everything else up to the last remaining ' backslash leaving just the directory name strDirectory = Mid(strPathOnly, intBackslashPos+1)The InStrRev() function finds the first location of a character string starting at the end of the searched string and going right to left. I broke out the backslash locating code in the above example to show how I used it. In practice however, I would embed the InStrRev() functions in the Mid() functions like this:
' Get the full path for the page including the page name strFullPath = Request.ServerVariables("PATH_TRANSLATED") ' Strip off the file name and the last backslash strPathOnly = Mid(strFullPath,1,InStrRev(strFullPath,"\")-1) ' Now strip off everything else up to the last remaining ' backslash leaving just the directory name strDirectory = Mid(strPathOnly,InStrRev(strPathOnly,"\")+1)You could actually do the whole thing in one line of code, but it would be a little difficult to read and you would also end up making 4 references to the ServerVariables collection which is a performance hit. While the ServerVariables collection is full of little goodies like this, every reference to it involves a procedure call outside of the ASP processor to IIS, so it should only be used when necessary. If you're going to reference a particular ServerVariables item more than once in your code, assign the contents to a variable to avoid these out-of-process calls.