Results 1 to 14 of 14

Thread: Non Ole .txt File Properties

  1. #1

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9

    Question Non Ole .txt File Properties

    I have read & searched most of this forum and cannot find any reference as to how one can get the additional File Properties.

    Eg. a Text File in Windows XP Professional. If you right click it, you can get AuthorName & Category etc.

    I have tried using the DSodll.dll object, but that is only for OLE objects.

    Can anyone assist.

    I need to be able read & write to these properties. I have even tried to use the scrun scripting object.

    Any pointers? I will really appreciate it.

    Kind Regards

  2. #2
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    I have also wondered about those properties.... I believe they can be access directly from registry .... never did any investigation though ...

  3. #3

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9
    Thanks for confirming that I'm seeing things.

    I tried to find it in the registry, but to no avail. It does not seem to be in there.

    Any other takers on my problem?

  4. #4
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    I never realized there was such a thing at all till I saw this thread!. Did a little bit of googling and ended up here and there from where I got this
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim arrHeaders(34)
    3. Set objShell = CreateObject("Shell.Application")
    4. Set objFolder = objShell.Namespace("C:\")
    5. For i = 0 To 33
    6. arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
    7. Next
    8. For Each strFileName In objFolder.Items
    9. For i = 0 To 33
    10. Debug.Print i & vbTab & arrHeaders(i) _
    11. & ": " & objFolder.GetDetailsOf(strFileName, i)
    12. Next
    13. Next
    14. End Sub
    HTH

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  5. #5
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Or you can do things like:

    You need to install the DSOFILE.DLL first (attached in ZIP). Then this code will work:
    VB Code:
    1. Dim DSO, DSOprop
    2.    Set DSO = CreateObject("DSOleFile.PropertyReader")
    3.    Set DSOprop = DSO.GetDocumentProperties(tempFile)
    4.         DSOprop.Author = gAuthor
    5.         DSOprop.Title = myOlSel.Item(x).Subject
    6.         DSOprop.Category = myOlSel.Item(x).Categories
    7.    Set DSOprop = Nothing
    8.    Set DSO = Nothing
    The following properties are also available:
    "Subject: " & oDocProp.Subject
    "Category: " & oDocProp.Category
    "Company: " & oDocProp.Company
    "Manager: " & oDocProp.Manager
    "CLSID: " & oDocProp.CLSID
    "ProgID: " & oDocProp.ProgId
    "Word Count: " & oDocProp.WordCount
    "Page Count: " & oDocProp.PageCount
    "Paragraph Count: " & oDocProp.ParagraphCount
    "Line Count: " & oDocProp.LineCount
    "Character Count: " & oDocProp.CharacterCount
    "Character Count (w/spaces): " & oDocProp.CharacterCountWithSpaces
    "Byte Count: " & oDocProp.ByteCount
    "Slide Count: " & oDocProp.SlideCount
    "Note Count: " & oDocProp.PresentationNotes
    "Hidden Slides: " & oDocProp.HiddenSlides
    "MultimediaClips: " & oDocProp.MultimediaClips
    "Last Edited by: " & oDocProp.LastEditedBy
    "Date Created: " & oDocProp.DateCreated
    "Date Last Printed: " & oDocProp.DateLastPrinted
    "Date Last Saved: " & oDocProp.DateLastSaved
    "Total Editing Time (mins): " & oDocProp.TotalEditTime
    "Version: " & oDocProp.Version
    "Revision Number: " & oDocProp.RevisionNumber
    "Template Name: " & oDocProp.Template
    "Presentation Format: " & oDocProp.PresentationFormat
    Attached Files Attached Files

  6. #6

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9

    Question Almost But No Cigar

    Hi Guys,

    Thanks for the help & directions so far, but all the options given so far does not give me the full control over these properties.

    The method JordanChris mentioned works only for OLE objects & not a plain txt file. Yes I can use a Word Document or something like that , but then I have to live with that specific format. Not really what I want.


    The Shell Method from KayJay works for retrieving the info from the text file, but I have no way of writing to these properties.

    Any ideas? This seems to be a nice challenge...any takers?

  7. #7
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  8. #8
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    I managed to get this done. It works but the details are not showing up in the Shell GUI (Right Click --> Properties --> Summary) though the code returns the correct values on retrieval
    VB Code:
    1. Option Explicit
    2. Private Sub Command1_Click()
    3. Dim strFileName As String
    4.  
    5. strFileName = "D:\text.txt"
    6.  
    7. WriteStream strFileName, "Author", "Kaushik Janardhanan"
    8. WriteStream strFileName, "Category", "VB Code Snippets"
    9. WriteStream strFileName, "Comments", "This stuff is really usefull! Thanx for the heads up SpaceRaider"
    10. WriteStream strFileName, "Title", "NTFS File Streams"
    11. WriteStream strFileName, "Reference", "VBFORUMS-1234"
    12.  
    13. MsgBox "Author" & vbCrLf & ReadStream(strFileName, "Author") & _
    14. vbCrLf & vbCrLf & _
    15. "Category" & vbCrLf & ReadStream(strFileName, "Category") & _
    16. vbCrLf & vbCrLf & _
    17. "Comments" & vbCrLf & ReadStream(strFileName, "Comments") & _
    18. vbCrLf & vbCrLf & _
    19. "Title" & vbCrLf & ReadStream(strFileName, "Title") & _
    20. vbCrLf & vbCrLf & _
    21. "Reference" & vbCrLf & ReadStream(strFileName, "Reference")
    22.  
    23. Unload Me
    24.  
    25. End Sub
    26.  
    27. Private Sub WriteStream(strFile As String, strStream As String, strContents As String)
    28. Dim intFN As Integer
    29.  
    30. intFN = FreeFile
    31.  
    32. Open strFile & ":" & strStream For Binary As #intFN
    33.     Put #intFN, , strContents
    34. Close #intFN
    35.  
    36. End Sub
    37.  
    38. Private Function ReadStream(strFile As String, strStream As String) As String
    39. Dim intFN As Integer
    40. Dim strTemp As String
    41.  
    42. intFN = FreeFile
    43.  
    44. Open strFile & ":" & strStream For Binary As #intFN
    45.     strTemp = Space(LOF(intFN))
    46.     Get #intFN, , strTemp
    47. Close #intFN
    48.  
    49. ReadStream = strTemp
    50.  
    51. End Function

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  9. #9

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9

    Thank you!

    STREAMS - This seems to be the route to go KayJay and I can use it, but I would still like to know how to access the Main Stream as explained in the article.

    The solution you have given here is for all the extra streams supported by NTFS & win32 file systems as pointed out by the article. Unfortunately you will not be able to keep the info intact
    when copying the file to non NTFS & WIN32 file systems, like CD's or floppy drives etc.

    I am particularly interested in retrieving the main streams information that's supported since win3.1. The image below indicates the main stream.


    Under an NTFS file system each file can have multiple streams of data. It's worth pointing out that streams are not a feature of NTFS 2000, but they have been in existence since Windows NT 3.1. When you read the content of a file under a non-NTFS volume (say, a disk partition of a Windows 98 machine) you're able to access only one stream of data. Consequently, you perceive it as the real and "unique" content for that file. Such a main stream has no name and is the only one that non-NTFS file systems can handle. But when you create a file on an NTFS volume, things might be different. Look at Figure 1 to understand the big picture.


    I am leaving this post to see if anyone else has ideas. I suspect that the Author info, when viewing the properties tab from the file is stored in this stream.

    Thank you very much KayJay.This has helped me immensely & I certainly will be able to use it. I will just have to make sure we dont need any backward compatibility. I can definately recommend this forum.

  10. #10

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9

    Nope - I was wrong

    I think my assumptions about the Main Stream was also wrong. The fact is when you copy the file to floppy drive, all that info is gone. What a waste

    Do any of you have some ideas to try and keep the info when copying these files to non NTFS partitions, like keeping a register file with info of all files in a single file. Then write an app to re-write the stream info from this register file when copying it from the disk etc.

    Any ideas?

  11. #11
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    U could create two separate routines (Copy and Paste) which read the various streams, deposit them in a hierarchical/structured single-stream file and while pasting writes back those streams onto the NTFS Volumes for the files.

    Copy Routine
    1) Read file contents
    2) Read all the different streams
    3) Store the above in a Flat - File as a User Defined Type
    4) Move that file onto a FAT16 or FAT32 Volume

    Paste Routine
    1) Read the Flat File from a FAT16 or a FAT32 Volume into the User Defined Type
    2) Write the file onto the target NTFS Volume with its contents
    3) Write each stream and its contents

    HTH

    PS: I have posted some rudimentary code here for a more generalised treatment on multiple streams on NTFS Volumes.

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  12. #12

    Thread Starter
    New Member SpaceRaider's Avatar
    Join Date
    Feb 2003
    Location
    South-Africa
    Posts
    9

    Cool Thank you

    I have meant to post my thanks in this thread. lol
    Thank you for your time and effort so far.

    I am going to put a class together incorporating all the functionality so far, but I would like to keep this thread open untill someone can show us how to get that Author & Comments Properties that does not seem to be part of the additional streams.

    Once Im done with the Class & you don't mind me using some of your code & ideas, I would like to make it available for your code bank.

    Cheers
    Spacy

  13. #13
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Ur Welcome. Mind? I would be delighted!

    Cheers & Good Luck

    Regards

    Kaushik Janardhanan

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  14. #14
    New Member
    Join Date
    Jan 2005
    Posts
    13

    Re: Non Ole .txt File Properties

    Private Sub WriteStream(strFile As String, strStream As String, strContents As String)
    Dim intFN As Integer

    intFN = FreeFile

    Open strFile & ":" & strStream For Binary As #intFN
    Put #intFN, , strContents
    Close #intFN

    End Sub
    KayJay, the above code is giving me troubles..it is giving file not found message - 53..any help?

Posting Permissions

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



Click Here to Expand Forum to Full Width