Reputation: 2970
Here is the VB.NET method currently used, which works just fine.
Private Sub editMetadata(ByRef bmp1 As Bitmap, ByVal intTitleId As Integer, ByVal strTitle As String)
Dim ci As System.Reflection.ConstructorInfo = _
GetType(PropertyItem).GetConstructor(BindingFlags.NonPublic Or _
BindingFlags.Instance Or BindingFlags.[Public], Nothing, New Type() {}, Nothing)
Dim outPropertyItem As PropertyItem = DirectCast(ci.Invoke(Nothing), PropertyItem)
outPropertyItem.Id = intTitleId
' Type=1 means Array of Bytes.
outPropertyItem.Type = 1
outPropertyItem.Len = strTitle.Length
outPropertyItem.Value = Encoding.Unicode.GetBytes(strTitle)
bmp1.SetPropertyItem(outPropertyItem)
End Sub
Now in C#, I've run into a road block with the very first line of this method.
System.Reflection.ConstructorInfo ci =
GetType(PropertyItem).GetConstructor( BindingFlags.NonPublic ||
BindingFlags.Instance || BindingFlags.[Public], null, new Type() {}, null);
After converting syntax from VB to C# (what I'm familiar with) I've still got 6 errors on this one section.
So, the issue could be solved a couple ways...
What's the right C# syntax for the code shown above.
OR..
How do I edit the files metadata correctly in C#.
Thank you for any help!
Upvotes: 2
Views: 492
Reputation: 2708
System.Reflection.ConstructorInfo ci =
typeof(PropertyItem).GetConstructor( BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Public, null, new Type[] {}, null);
Upvotes: 3