Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > FileSystemObject: how to get a file's title

Reply
Thread Tools

FileSystemObject: how to get a file's title

 
 
fniles
Guest
Posts: n/a
 
      09-10-2008
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


 
Reply With Quote
 
 
 
 
Old Pedant
Guest
Posts: n/a
 
      09-10-2008
"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


 
Reply With Quote
 
 
 
 
fniles
Guest
Posts: n/a
 
      09-12-2008
Thank you

"Old Pedant" <> wrote in message
news:912131A9-CD6C-4B3C-B97B-...
> "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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Friendly Urls with page title in (eg. page-title.aspx) anthonykallay@googlemail.com ASP .Net 1 04-24-2007 08:25 AM
How 2 place page title into window title using sitemap in master page? bednar.tomas@gmail.com ASP .Net 0 11-30-2006 03:17 PM
Does anyone know the title of the first ever DVD title released? (UK/US) Mikey DVD Video 12 09-23-2006 07:14 PM
Fastest way to get a the string between <title> </title> Andreas Klemt ASP .Net 1 08-10-2003 01:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57