I'd like to ask a question about file summary information, I've googled this extensively over the weekend and the feedback I am getting is somewhat frustrating.
What I wish to do is either create a file with summary information, or change summary information in an existing file.
Now, so far I have been pointed to the DSOFile Dll, which is a neat little Dll for setting author information, comments, etc. Problem is, no matter what I do I cannot set the company, the property is there, but the changes do not apply when you call the Save() method. It may be prudent to mention that I am trying to set information on .exe files, I am pretty sure the class was written for .doc files (judging by the properties it exposes), and ironically the main summary information I wish to change is the 'Description', and that isn't even exposed by the class at all!!
I'm pretty sure there isn't a .Net method to do this, so I'm thinking API, but I'm not joking when I say I have spent the entire weekend fighting with google keywords to find a solution, and I have failed, so have others too, discussion boards are full of this particular challenge.
Does anyone have any ideas about this?
Thanks in advance,
MikeMonday, October 13, 2008 8:38 AM
I found a nice little webpage on a blog that describes how the information is stored, and the API functions used to get the information here
Now, this is all well and good, since there is no API methods to set the information (it would seem), I'll just have to parse the information into structures or classes and rewrite the modified values back to the file, I'm willing to do this.
So, this leaves me with a question regarding where the exe file binary should go, I can only assume that the OS takes care of skipping this structure, and program source should go directly after the VS_VERSION_INFO block, but I'm unsure. I guess since there is little interest in the forums for achieving this it will be a trial and error thing until I crack it.
Lots of programs and utilities set this information on newly created files, I cannot believe there is not a resource geared to creating files with set properties, maybe I'll write a component that handles it all, we'll see.Tuesday, October 14, 2008 7:33 AM
Have a look at this thread. It should satisfy your requirement.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filename As String = "C:\Scenarios.docx"
'Create the OleDocumentProperties object.
Dim dso As New DSOFile.OleDocumentProperties()
'Open the file for writing if we can. If not we will get an exception.
dso.Open(filename, False, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess)
'Set the summary properties that you want.
dso.SummaryProperties.Title = "This is the Title"
dso.SummaryProperties.Subject = "This is the Subject"
dso.SummaryProperties.Company = "test"
dso.SummaryProperties.Author = "Riquel"
'Save the Summary information.
'Close the file.
End ClassTuesday, October 14, 2008 9:05 AM
Thanks for replying, I was thinking I posted a dead duck.
If you look at my first post, you'll see I already tried that, the problem with the DSOfile object is twofold.
Firstly it seems to be primarily for .doc files (your example is based on a .doc file), and the methods don't work 100% of the time (you'll find this problem common amongst the blogs), I tried several variations to set the 'Company' property on my .exe file with no success using this, although the 'Comments' property would set every time.
Secondly, the object doesn't expose the 'Description' property, and that is the goal of what I wish to achieve. It's worth mentioning that I had no idea the DSOfile object was part of the IO namespace, I downloaded it from the microsoft website, so maybe I have a version that's qwerky.
I think I am resigned to creating my own FileInfo structure, saving that as a binary file, then appending my clean exe's source (exe file containing no fileinfo) to the end. Another way is to set all the properties on the exe file when you build it, but with padded out values, then you could, theoretically, just parse the fileinfo structure and replace the padded values with whatever you want (as long as you null terminate the value), I'm trying not to do this, however, as I dont really want any limitations as to property value length.
I will continue to look for a solution and post it here when that happens, I have no doubt that persons wishing to create files/compilers with file properties would find it useful. You know, I am still amazed that the windows API doesnt do this, versioninfo dates back to win95, and so many programs and utilities set this information on newly created files, Visual Studio sets it when it builds the primary output, do they all have to go round the houses to set the properties in there?Tuesday, October 14, 2008 10:23 AM
I was wondering if you ever solved this? I am wanting to edit one of the summary fields (probably Comments).
In fact I don't think DSOfile is part of the IO namespace, and I would prefer not to have to ship another DLL, esp for an unmanaged solution.
I would have thought there would be a .Net way to do this elegantly, but I can't find the solution, despite much searching.
Any help would be appreciated.
TimMonday, November 09, 2009 7:19 PM