Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2006, 10:48 PM
Registered User
 
Join Date: Mar 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using FSO to get Last Folder Name in URL

I am writing a site that I structured like:
mysite.com/yourplaceNAME

YourplaceNAME changes all the time as users set up their pages.

I have a default.asp page that sits in each dir and populates info depending on the directory name - in the above example yourplaceNAME

To get the dir name I have used

Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Path=request.querystring("\")
Set ts=fso.GetFolder(Server.MapPath("\"))
Set folder = fso.GetFolder(Server.Mappath("\"))

Set subFolders = folder.SubFolders
For Each folderObject in SubFolders
strDirectory = folderObject.Name  'make dir name string for db
But it does not get the current dir that I am in eg:
mysite.com/yourplaceNAME
instead it gives a different dir and then the code will either give the wrong info, or no info.

Could someone help me to get the name of the dir that I am in?

Thank you for your time :)

 
Old March 30th, 2006, 09:05 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First look into URL MOD REWRITING, if thats a relatively large website your directory structure will become a nightmare (not to mention a preformance issue). Moving on I am about willing to bet that your Path variable equals "" after you call request.querystring. (if anything it may contain a \) Anyway. I see 2 options here: 1)Request the entire URL into a variable then use string manipulation to find the last occurance of '\' and then a substring function that starts at the index of the '\' + 1 and ends at string.length - string.lastindexof("\") + 1 or 2) setup your url's as mysite.com?dir=yourplacename and then call request.querystring("dir")

Hope this helps.

"The one language all programmers understand is profanity."
 
Old April 1st, 2006, 07:55 PM
Registered User
 
Join Date: Mar 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you dparsons - that helped and I now have it working :-)

Thank you once again for your guidence :-))






Similar Threads
Thread Thread Starter Forum Replies Last Post
App_Code folder shared on only 1 folder? rpeters83 ASP.NET 2.0 Professional 1 September 1st, 2006 10:53 PM
Making a folder virtual folder on button click in CsharpHelp C# 0 October 26th, 2005 05:57 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
FSO mikedeepak Classic ASP Databases 5 August 4th, 2004 05:55 AM
FSO mikedeepak Classic ASP Databases 0 August 4th, 2004 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.