ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 7th, 2002, 02:10 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
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!

Reply With Quote
  #2  
Old November 7th, 2002, 02:30 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 17
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
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

Reply With Quote
  #3  
Old November 7th, 2002, 02:33 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
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.

Reply With Quote
  #4  
Old November 7th, 2002, 02:40 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 17
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
path?

Maybe the path property?
Code:
Response.Write FileObject.Path

Reply With Quote
  #5  
Old November 7th, 2002, 02:53 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
Don't I need to split it at the / or something?

Reply With Quote
  #6  
Old November 7th, 2002, 03:48 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 17
Send a message via MSN to aspnewbie
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > How Do You Get The Folder Name?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap