jeudi 16 février 2017

update extended file propertys - replace property with string

I am trying to update extended file properties. I am using .Net Framework 4.5.2 I have found that this can be done with the following code and using Microsoft.WindowsAPICodePack.Shell library

    Dim File = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(Filename)
    File.Properties.System.Keywords.Value = New String() {"Tag1", "Tag2"}

My problem is that I need to make it a little more flexible, as there are some 300 combinations of extended propery its not really realistic to list them all.

I would like to know how I can replace "Keywords" with a variable ie:

 Dim strTags as string = "Keywords"
 File.Properties.System.(strTags).Value = New String() {"Tag1", "Tag2"}

I have investigated CallByName() but I don't see how to make that work. Perhaps someone has a piece of VB.Net code to solve my problem?





Aucun commentaire:

Enregistrer un commentaire