【问题标题】:SSIS: Create Folder & Archive File in one taskSSIS:在一项任务中创建文件夹和存档文件
【发布时间】:2017-07-10 22:19:43
【问题描述】:

我有 SSIS 包,它会加载一些数据并最终将文件存档在某些文件夹中。

"如果存档文件夹不存在则创建" 只需用OverwriteDestinationFile=True 做一个简单的Operation "Create Directory"

“归档输入文件” 会做一个Operation "RenameFile" 基本上只是将文件路径从加载目录更改为存档目录

我只是在移动/重命名文件之前使用第一个任务来保证目标目录存在。

我不能一步完成这两项任务吗?

【问题讨论】:

    标签: visual-studio ssis


    【解决方案1】:

    是的,有可能。您需要编写脚本。

    创建 2 个变量。源路径和目标路径。

    命名空间:using System.IO;

        string fileName = "test.txt"; //file name
        string sourcePath = Dts.Variables["User::var_source"].Value.ToString(); //source path
        string targetPath = Dts.Variables["User::var_destination"].Value.ToString(); //destination path with folder
    
        string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
        string destFile = System.IO.Path.Combine(targetPath, fileName);
    
        if (!System.IO.Directory.Exists(targetPath))
        {
            System.IO.Directory.CreateDirectory(targetPath);
        }
    
        System.IO.File.Copy(sourceFile, destFile, true);
    

    截图:

    【讨论】:

    • 谢谢 - 当我有时间的时候,我会像你说的那样尝试 id。目前正在努力解决工作中的其他一些问题^^
    • 是的。标记我,以防你被卡住。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2011-03-13
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多