FileSystemObject: how to get a file's title

Discussion in 'ASP General' started by fniles, Sep 10, 2008.

  1. fniles

    fniles Guest

    I am using the FileSystemObject to display the content of a directory/folder
    in a browser.
    I am wondering if there is a way for me to get/show the file's title (this
    is the one in the property of the file, in the "Summary" tab, not the name
    of the file).
    I do not see the property in the file object to get the file's title.
    Thank you.

    strPhysicalPath = Server.MapPath(strPath)
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strPhysicalPath)

    Set objCollection = objFolder.Files
    For Each objItem in objCollection
    strName = objItem.Name
    next
     
    fniles, Sep 10, 2008
    #1
    1. Advertising

  2. fniles

    Old Pedant Guest

    "fniles" wrote:

    > I am wondering if there is a way for me to get/show the file's title (this
    > is the one in the property of the file, in the "Summary" tab, not the name
    > of the file).


    Yes, but *NOT* via the FileSystemObject.

    Here's a little demo I wrote that gets all the info possible about any given
    file:

    <%
    ' you need the absolute path to the file
    ' here, I'm getting a file in the same directory as the ASP code
    ' so adjust as needed for your situation
    fname = "xyz.doc"
    fl = Server.MapPath( fname )
    ' this object is the magic to the whole thing:
    Set objShell = Server.CreateObject("Shell.Application")
    Set objFolder = objShell.NameSpace( Left( fl, InStrRev( fl, "\" )-1 ) )
    If Not( objFolder IS Nothing ) Then
    Set objFolderItem = objFolder.ParseName( fname )
    If Not( objFolderItem Is Nothing ) Then
    ' in actuality, only the numbers from 0 to about 20 or so and
    ' then a few numbers right after 1000 are ever used,
    ' so far as I can tell...but this overkill won't hurt:
    For infoNumber = 0 To 2000
    info = ""
    On Error Resume Next
    info = Trim( objFolder.GetDetailsOf(objFolderItem,
    infoNumber) )
    On Error GoTo 0
    If info <> "" Then
    Response.Write infoNumber & ": " & info & "<br/>"
    End If
    Next
    End If
    End If
    %>

    So now you can figure out which value of infoNumber corresponds to "title"
    and just use that directly, instead of my clumsy (but informative!) FOR loop.

    (HINT: infoNumber 10 is the title.)

    Oh, what the hey...here is the output I get from looking at a "Feeds.doc"
    file on my machine:

    0: Feeds
    1: 44 KB
    2: Microsoft Word Document
    3: 5/14/2008 6:42 PM
    4: 9/10/2008 1:06 PM
    5: 9/10/2008 1:06 PM
    6: A
    7: Online
    8: PRIVATE\bwilkinson
    9: bwilkinson
    10: Feeds, Feed Management, and Feed Reconfiguration
    13: 1
    31: 5/14/2008 11:15 AM

    6 is "A"rchive.
    8 is owner, 9 is author. 0 through 6 should be obvious.
    I don't know what infoNumber 13 or 31 are for.
    Oh, and try this with an image file. You'll get the size of the image.
    Example:

    0: upArrow
    1: 1 KB
    2: JPEG Image
    3: 9/17/2007 11:27 AM
    4: 10/4/2007 2:22 PM
    5: 9/10/2008 1:03 PM
    6: RA
    7: Online
    8: PRIVATE\bwilkinson
    13: 1
    26: 11 x 12
    27: 11 pixels
    28: 12 pixels
     
    Old Pedant, Sep 10, 2008
    #2
    1. Advertising

  3. fniles

    fniles Guest

    Thank you

    "Old Pedant" <> wrote in message
    news:...
    > "fniles" wrote:
    >
    >> I am wondering if there is a way for me to get/show the file's title
    >> (this
    >> is the one in the property of the file, in the "Summary" tab, not the
    >> name
    >> of the file).

    >
    > Yes, but *NOT* via the FileSystemObject.
    >
    > Here's a little demo I wrote that gets all the info possible about any
    > given
    > file:
    >
    > <%
    > ' you need the absolute path to the file
    > ' here, I'm getting a file in the same directory as the ASP code
    > ' so adjust as needed for your situation
    > fname = "xyz.doc"
    > fl = Server.MapPath( fname )
    > ' this object is the magic to the whole thing:
    > Set objShell = Server.CreateObject("Shell.Application")
    > Set objFolder = objShell.NameSpace( Left( fl, InStrRev( fl, "\" )-1 ) )
    > If Not( objFolder IS Nothing ) Then
    > Set objFolderItem = objFolder.ParseName( fname )
    > If Not( objFolderItem Is Nothing ) Then
    > ' in actuality, only the numbers from 0 to about 20 or so and
    > ' then a few numbers right after 1000 are ever used,
    > ' so far as I can tell...but this overkill won't hurt:
    > For infoNumber = 0 To 2000
    > info = ""
    > On Error Resume Next
    > info = Trim( objFolder.GetDetailsOf(objFolderItem,
    > infoNumber) )
    > On Error GoTo 0
    > If info <> "" Then
    > Response.Write infoNumber & ": " & info & "<br/>"
    > End If
    > Next
    > End If
    > End If
    > %>
    >
    > So now you can figure out which value of infoNumber corresponds to "title"
    > and just use that directly, instead of my clumsy (but informative!) FOR
    > loop.
    >
    > (HINT: infoNumber 10 is the title.)
    >
    > Oh, what the hey...here is the output I get from looking at a "Feeds.doc"
    > file on my machine:
    >
    > 0: Feeds
    > 1: 44 KB
    > 2: Microsoft Word Document
    > 3: 5/14/2008 6:42 PM
    > 4: 9/10/2008 1:06 PM
    > 5: 9/10/2008 1:06 PM
    > 6: A
    > 7: Online
    > 8: PRIVATE\bwilkinson
    > 9: bwilkinson
    > 10: Feeds, Feed Management, and Feed Reconfiguration
    > 13: 1
    > 31: 5/14/2008 11:15 AM
    >
    > 6 is "A"rchive.
    > 8 is owner, 9 is author. 0 through 6 should be obvious.
    > I don't know what infoNumber 13 or 31 are for.
    > Oh, and try this with an image file. You'll get the size of the image.
    > Example:
    >
    > 0: upArrow
    > 1: 1 KB
    > 2: JPEG Image
    > 3: 9/17/2007 11:27 AM
    > 4: 10/4/2007 2:22 PM
    > 5: 9/10/2008 1:03 PM
    > 6: RA
    > 7: Online
    > 8: PRIVATE\bwilkinson
    > 13: 1
    > 26: 11 x 12
    > 27: 11 pixels
    > 28: 12 pixels
    >
    >
     
    fniles, Sep 12, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    1
    Views:
    465
    Steve C. Orr, MCSD
    Aug 10, 2003
  2. Replies:
    0
    Views:
    538
  3. Replies:
    1
    Views:
    554
    David
    Apr 24, 2007
  4. soonic
    Replies:
    11
    Views:
    1,783
    soonic
    Jul 27, 2011
  5. Replies:
    2
    Views:
    111
Loading...

Share This Page