How to read file properties (metadata) ?
Hi I just need to know how can I read file properties (metadata) using integration services package. By file metadata I mean file properties which are visible when you right click on the file and select "Properties". There you get to see file creation date, modified date, access date. BasicallyI need to read this information. Early Thanks, Salman Shehbaz.
November 25th, 2008 11:08am

You can create a Script Task, and then make use of FIleInfo to get the information that you need and write toa variable. e.g. FileInfo fInfo = new FileInfo(@"c:\demo\test.txt"); Dts.Variables["User::fileCreationTime"].Value = fInfo.CreationTime.ToLongDateString(); This assumes you have created a variable call fileCreationTime (String), and you are getting the properties for the file test.txt. You can also do a search for File Properties Task (by Brian Knight).
Free Windows Admin Tool Kit Click here and download it now
November 25th, 2008 11:48am

Finally I googled it out ; its so simple; Public Sub Main() Dts.Variables("FileReceiveDate").Value = File.GetCreationTime(Dts.Variables("testxml").Value.ToString()) Dts.TaskResult = Dts.Results.Success End Sub Don't forget to include the following two in your code; Imports System.IO Imports System.Text Code Comments; Here FileReceiveDate is SSIS variable that will store file creation date. GetCreationTime is a builtin function in Visual Basic. testxml is SSIS variable that holds the path of the file, whose creation date needs to be known. Thanks.
November 25th, 2008 2:13pm

I've just created a Task that will allow you to read tons of those kinds of properties (dates, attributes): File Properties Task.
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2009 5:40pm

Hi ToddThat is what i call a real professional answer, Thanks againSincerely SH -- Please kindly dont forget to mark the post(s) that answered your question and/or vote for the post
August 6th, 2009 5:45pm

Here is a C# Script Task Example of getting file properties such as last modified, size, owner, etc. http://microsoft-ssis.blogspot.com/2011/03/get-file-properties-with-ssis.htmlPlease mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
March 13th, 2011 4:29pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics