dcsimg
Results 1 to 9 of 9

Thread: Accessing a file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    169

    Question Accessing a file

    I have a directory with pictures. With all pics I have the Comments attribute filled in. can change it to the Description attribute if needed.

    Sometimes when I need to load (display) the pic into the program, I do not have the file name. But, I always have the Comment. How can access the comment, then get the file name so I can show the pic?

    Thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,421

    Re: Accessing a file

    I would suppose that you would need to access each file and check the comment to see if it matches then when you find it load it.

    Another option would be to create a sort of index file where it lists the comments and the filename so you can look up the filename rather than accessing them all.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,065

    Re: Accessing a file

    Windows filesystems do not support arbitrary queries based on content.

    You could index the folder and make Windows Search queries to locate a file or files by their System.Comment property value. Or you could roll your own indexing database, scanner to keep it updated, and query support.

    That's assuming the phrase "access the comment" means what I thought you meant.

    Oops - Too slow.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    169

    Re: Accessing a file

    Maybe I need to be clearer. I know the Comments attribute (or the Description attribute) for a file in a specified directory. Each file will have a unique comments (or description) value. How do I search for that parameter and get the filename so I can open it?

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,448

    Re: Accessing a file

    This sounds like something FSO might be able to do or VB with IShellItem, by enumerating each file in the folder. I don't use FSO and don't know if it has ability to return the properties you are interested in. But IShellItem does.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,065

    Re: Accessing a file

    Quote Originally Posted by AccessShell View Post
    Maybe I need to be clearer. I know the Comments attribute (or the Description attribute) for a file in a specified directory. Each file will have a unique comments (or description) value. How do I search for that parameter and get the filename so I can open it?
    There really is no such thing as a "Comments" or "Description" file attribute. No Windows filesystem supports such a thing.

    What you are looking at is metadata that is contained within some file formats.

    Shell32/Explorer can extract those for well known file types or file types that have a custom Property Sheet Extension library installed.

    Current versions of Windows Search piggyback on this file properties subsystem.


    So you basically have 3 ways you can do this:

    • Use a Windows Search query after you have told Search to index the folder you are interested in.
    • Ask Shell to open and read each file and return to you the property value you are interested in, and when you find files of interest you can act upon them.
    • Read each file yourself and extract the information, assuming you have code that understands the file formats of interest.


    So in other words... what we already suggested above.

    The FSO is worthless for this.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,448

    Re: Accessing a file

    Quote Originally Posted by dilettante View Post
    The FSO is worthless for this.
    Bingo. I was thinking of the wrong reference, Shell was what I should've thought of.

    FYI for OP:
    1. Example of IShellItem via TLB: http://www.vbforums.com/showthread.p...rn-PROPERTYKEY
    2. Example of Shell reference: http://www.vbforums.com/showthread.p...ile-properties

    However, not sure properties is best way to identify a file. Obviously, the file name would be best
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,065

    Re: Accessing a file


  9. #9
    Frenzied Member
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,033

    Re: Accessing a file

    You're looking for System.Comment/PKEY_Comment, fmtid=F29F85E0-4FF9-1068-AB91-08002B27B3D9 pid=6 if the canonical name doesn't work on extendedproperty.

    @LaVolpe... I noticed the sample thread (2) you linked, the .ExtendedProperty method couldn't get GPS data? It almost certainly get Comment but the property store method in (1) can retrieve GPS data just fine (although that project won't show it by default, it's not in PDEF_VIEWABLE for some reason; PDEF_SYSTEM instead). If there's ever a property explorer can display, it's in the property store.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width