|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How Do You Get The Folder Name?
I know how to get the filename for the files in my directory using asp, but how do I find out the folder name that the particular file is in? Thanks in advance!
|
|
#2
|
|||
|
|||
|
with the Folder and File object
Hey AspNewbie,
You can get the file and folder names using the Vbscript FileSystemObject. Here a snippet for the folders: Code:
Dim oFSO, oFolder, oSubFolder, i
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("c:\somewhere")
Set oSubFolder = oFolder.SubFolders
For Each i in oSubFolder
Response.Write i.Name & "<BR>"
Next
something similar for the files: Code:
Dim oFSO, oFolder, oFiles, i
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("c:\somewhere")
Set oFiles = oFolder.Files
For Each i In oFiles
Response.Write i.Name & "<BR>"
Next
as always: happy coding!
__________________
- Rogier Doekes |
|
#3
|
|||
|
|||
|
Thanks Rogier, who knoweth all!
Okay, in this case, though I am using a search of the index server catalog and it retrieves the file name and full path. Is there a way to get the folder name out of the full path? Last edited by aspnewbie : November 7th, 2002 at 02:38 PM. |
|
#4
|
|||
|
|||
|
path?
Maybe the path property?
Code:
Response.Write FileObject.Path |
|
#5
|
|||
|
|||
|
Don't I need to split it at the / or something?
|
|
#6
|
|||
|
|||
|
Rogier got it to work for anyone who's interested! Here's the code
Code:
aSplit = Split (oFilename.path, "\")
UBound(aSplit)
If UBound(aSplit) > 1 Then
Response.WRite "the folder is: " & aSplit(Ubound(aSplit) - 1) & "<BR>"
End If
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > How Do You Get The Folder Name? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|