Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return folder name wihtout path for web page output

Status
Not open for further replies.

cdck

Programmer
Nov 25, 2003
281
US
I am writing a web page intended to list the subfolders included in a root folder. I do not want the full path name to show in the list, only the name of the folder itself. The references I have found tell me to use the ShortName property to achevie this, but in use, I get an error.

Here is the code I am using (path name replaced with **** for privacy)

[tt]
25 Dim FSobj, FldObj, FldCollObj
26 Set FSOBJ = Server.CreateObject("Scripting.FileSystemObject")
27 Set FldObj = FSObj.GetFolder("c:\**\**\**\**\picart")
28 Set FldCollObj = FldObj.SubFolders
29 For Each Item In FldCollObj
30 Response.write("<LI>" & Item.ShortName & "</LI>")
31 Next
[/tt]

This is the error that results:
[tt]
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument
/picart/index.asp, line 30
[/tt]

If the same code is used without the ShortName property called on item, it works properly, but displays the entire path for each item.

How can I write only the folder name to the web page for each item?

Cheryl dc Kern
 
I am unable to determine why ShortName wouldn't work, but when i replaced ShortName with Name, I got the result that I wanted. Presumably, if ShortName had worked as expected, it would shorten the name of any folder that was more than 8 characters long.

Cheryl dc Kern
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top