2015-07-22 142 views
5

我們有一個SSIS過程,可以從各種來源導入不同格式的各種文件。 這些文件中的每一個都在整個月的不同時間交付。SSIS讀取文件修改日期

用戶希望能夠看到每個文件的修改日期,以檢查他們是否獲得定期更新。

其目的是在過程的這樣的端產生一個表:

Desired Table

所以我試圖找出如何讓每一個我有文件的修改日期閱讀。有沒有辦法在SSIS中做到這一點?

在此先感謝

回答

7

您可以添加腳本組件的管道從一個輸入變量讀取文件名,並寫入文件的修改日期輸出變量:

/// <summary> 
    /// This method is called when this script task executes in the control flow. 
    /// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. 
    /// To open Help, press F1. 
    /// </summary> 
    public void Main() 
    { 
     System.IO.FileInfo theFile = 
       new System.IO.FileInfo(Dts.Variables["User::FilePath"].Value.ToString()); 

     if (theFile.Exists) 
     { 
      Dts.Variables["User::LastFileDate"].Value = theFile.LastWriteTime; 
     } 
     Dts.TaskResult = (int)ScriptResults.Success; 
    } 
+0

非常感謝@Steve ,我會試一試,看看它是如何發展的。 – Lobsterpants

+0

是完美的 - 非常感謝 – Lobsterpants

相關問題