Thursday, January 28, 2010

Read or Write OLE File Property

Here are the steps to Read or Write the properties of files [Title, Subject, Author and Comments]




- Add reference to C:\DsoFile\dsofile.dll to your project (this is the default location)
 
private void Button1_Click(object sender, EventArgs e)
{
  //This is the PDF file we want to update.
  string strFilename = @"c:\Test.pdf";
  //Create OleDocumentProperties object.
  DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
  dso.Open(strFilename, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);


  dso.SummaryProperties.Title = "Test Title";
  dso.SummaryProperties.Subject = "Test Subject";
  dso.SummaryProperties.Author = "Test Author";
  dso.SummaryProperties.Comments = "Test Comments";


  dso.Save();
  dso.Close(false);
}






If you want run the exe of this application in other system, you have to register dsofile.dll.
For that copy dsofile.dll in that system and in command prompt navigate to the directory where the dsofile.dll is present and run the regsvr32 command like below.


regsvr32 dsofile.dll

1 comment:

  1. I've been surfing online greater than three hours lately, but I never discovered any attention-grabbing article like yours. It'ѕ beautіful value еnough
    for me. In mу opinion, if аll ωeb οωneгs and bloggers mаde еxcellent content material as yоu dіd,
    the net shall bе much moгe helpful than evеr before.
    Have a look at my web page :: get senuke

    ReplyDelete