SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    showing file extension in directory browsing script

    If you'll notice, there's a comment in this snippet that drops the extension. How can this be modified so that the extension IS shown?

    Code:
    Set myFileSys = Server.CreateObject("Scripting.FileSystemObject")
       Set Folder = myFileSys.GetFolder(Server.MapPath("/meetings"))
       for each file in Folder.Files
    	If Not file.name = "index.asp" Then
    	FileName = Left(file.name, (Len(file.name) - 4)) 'drop the extension
    	FileSize = cint(file.size / 1024) 'convert into kilobytes and drop the decimal
    	Response.Write("<li><a href='/meetings/" & file.name & "'>" & FileName & "</a> - " & FileSize & " K<br>" & chr(13))
    	End If
       next
       
       Set myFileSys = nothing
    Thanks,
    Ash

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Place a ' in front of the line. That will comment the line out and not execute.
    Code:
    Set myFileSys = Server.CreateObject("Scripting.FileSystemObject") Set Folder = myFileSys.GetFolder(Server.MapPath("/meetings")) for each file in Folder.Files If Not file.name = "index.asp" Then ' FileName = Left(file.name, (Len(file.name) - 4)) 'drop the extension FileSize = cint(file.size / 1024) 'convert into kilobytes and drop the decimal Response.Write("<li><a href='/meetings/" & file.name & "'>" & FileName & "</a> - " & FileSize & " K<br>" & chr(13)) End If next Set myFileSys = nothing

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    USA
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Commenting that line excludes the entire filename, leaving only the file size. What else can I try?

    Ash

  4. #4
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    opps read it too quickly. Here ya go:

    Code:
    Set myFileSys = Server.CreateObject("Scripting.FileSystemObject") Set Folder = myFileSys.GetFolder(Server.MapPath("/meetings")) for each file in Folder.Files If Not file.name = "index.asp" Then FileName = file.name 'drop the extension FileSize = cint(file.size / 1024) 'convert into kilobytes and drop the decimal Response.Write("<li><a href='/meetings/" & file.name & "'>" & FileName & "</a> - " & FileSize & " K<br>" & chr(13)) End If next Set myFileSys = nothing



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •