Wednesday, March 21, 2012

SSIS File Custom Attributes

Today I was given a requirement to extract custom attributes of files and then update the database with these value.


Searching for a DLL's lead me to this URL:-Interop.DsoFile.Dll from Microsoft. Once you download and extract the files go to the Demo folder and use the Interop.dsofile.dll. The dsofile.dll in the main directory is a COM DLL and not .NET dll. 


Using Interop.Dsofile.Dll
To use it in SSIS-Script task, copy the file to "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\binn".
Add a script task and add this dll as reference from "Add Reference". Access the custom attributes using the code below
DSOFile.OleDocumentPropertiesClass _file;
_file = new DSOFile.OleDocumentPropertiesClass();
            
_file.Open(@"C:\TestFile.doc", false,
DSOFile.dsoFileOpenOptions.dsoOptionDefault);

MessageBox.Show(_file.CustomProperties.Count.ToString());

MessageBox.Show(_file.CustomProperties[0].Name.ToString() + ":-" + _file.CustomProperties[0].get_Value().ToString());


1 comment:

  1. Issues surrounding bin checker can never be over analyzed. Many an afternoon has been enjoyed by a family, bonding over the discussion of bin checker. Until recently considered taboo amongst polite society, it is important to remember that ‘what goes up must come down.’ It still has the power to shock those most reliant on technology, who just doesn’t like that sort of thing. Relax, sit back and gasp as I display the rich tapestries of bin checker.

    ReplyDelete

Note: Only a member of this blog may post a comment.

LinkWithin

Related Posts with Thumbnails