Monday, October 29, 2007 4:04 PMHello forum,
I've searched the forum in vain.
How can i set the file info (author, subject) of a file (PDF) as i can in
the properties dialog on the 'info' tab of the file properties?
In my opinion these options are available for all files in an ntfs
file system. So it must possible to change them with c#, or
am i wrong?
Monday, October 29, 2007 7:50 PMYou can get at some of the Summary information like the CreationTime and LastAccessTime from the System.IO.FileInfo object. But I don't know of a way to get at the author, subject, etc.. values using just the .Net classes.
I found this article that explains how to get at these values using the "OLE File Property Reader" COM object.
Hope this helps.
Monday, October 29, 2007 9:10 PMAfter playing around with the "OLE File Property Reader" a bit. This is what I found out.
- You need to download the "Microsoft Developer Support OLE File Property Reader 2.1 Sample" from
- Create a new C# VS.NET project (I used a windows application in this case).
- Add a reference to C:\DsoFile\dsofile.dll to you project (this was the default location).
- Add a button to the form.
- Add the following code to the button:
private void button1_Click(object sender, EventArgs e)
//This is the PDF file we want to update.
string filename = @"c:\temp\MyFile.pdf";
//Create the OleDocumentProperties object.
DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
//Open the file for writing if we can. If not we will get an exception.
//Set the summary properties that you want.
dso.SummaryProperties.Title = "This is the Title";
dso.SummaryProperties.Subject = "This is the Subject";
dso.SummaryProperties.Company = "RTDev";
dso.SummaryProperties.Author = "Ron T.";
//Save the Summary information.
//Close the file.
This will update the Title, Subject, Company and Author of the MyFile.pdf file.
Tuesday, October 30, 2007 3:19 AM
You can implement this through the "Microsoft Shell Controls and Automation" (shell32.dll). For detailed information, you can visit:
Tuesday, October 30, 2007 12:46 PMThanks everybody.
Using the dsofile.dll makes it possible. But i would prefer a solution that doesn't
need a additional DLL.
Using shell32.dll only allows reading but not writing attributes as far as i see.
Wednesday, October 31, 2007 1:56 AM
Yes, I know what you mean. It would me nice to not need any additional DLL's. Maybe the .Net framework will add support for this in the next version of the framework.
Wednesday, October 31, 2007 12:39 PMHello again,
i'm trying to use the dsofile.dll to set the file info and on my development PC
everything works well. But on another machine i get an exception that the
COM-object hasn't been registerd.
Do i have to register the DLL? Isn't there another way?
Wednesday, October 31, 2007 1:49 PMYes, the dsofile.dll is a COM object and needs to be registered.
At the command line navigate to the directory where the dsofile.dll and run the regsvr32 command.
Example: regsvr32 dsofile.dll
Thursday, November 01, 2007 6:10 PM
DSO file works great for what I need to do. The problem that I am having now is how do I automatically register that dll on a machine that I have published my application to?
Sunday, January 06, 2008 1:17 AMI think if you use an installer, you can get it to register DLLs, etc. for you.
For example, here is a freeware installer (I haven't tried it, just found it on a search...) that claims to do just that:
On the main topic... I've been trying to write a little file Detail/Property editor that will work for all files and all details... Particularly on Vista with all the (new?) file details available.
It seems that DSO should work, but I haven't tried it yet for some of the non-standard details that you see when you're in a folder in Vista, and click View -> Choose Details (Like Light Source, Link target, Mailing address, Mileage, Nickname, etc, etc.)
I checked out the example someone linked to above on The Code Project which also looks interesting, and uses Shell32.dll instead.
I *also* see a page called "Property Handlers" on MSDN at:
Which talks about Vista's "Open Metadata" that sounds like you can add whatever property/value pairs you want to a file... somehow.. :-/
Still trying to figure what's best/most flexible, etc...
Wednesday, August 26, 2009 4:33 PMI tried this with an .mp3 file. I got all the code to run, but the mp3 title did not change. If not, what do I need to change MP3 information?
Wednesday, February 23, 2011 6:31 PMSame problem as cboshdave. Code works fine but the change is not refleced.
Saturday, September 08, 2012 1:35 AM
Same problem here. I can modify the properties of pdf file successfully. also the code runs for mp3 files without any error. but then when i look up properties of mp3 file i find no change.