Visual studio SSIS:创建文件夹&;在一个任务中归档文件

Visual studio SSIS:创建文件夹&;在一个任务中归档文件,visual-studio,ssis,Visual Studio,Ssis,我有SSIS包,它加载一些数据并最终将文件归档到某些文件夹中 “如果不存在,则创建存档文件夹” 只需使用OverwriteDestinationFile=True执行一个简单的操作“创建目录” “存档输入文件” 将执行操作“重命名文件” 基本上只是将文件路径从加载目录更改为归档目录 在移动/重命名文件之前,我只是使用第一个任务来确保目标目录存在 我不能一步完成这两项任务吗

我有SSIS包,它加载一些数据并最终将文件归档到某些文件夹中

“如果不存在,则创建存档文件夹” 只需使用
OverwriteDestinationFile=True执行一个简单的
操作“创建目录”

“存档输入文件” 将执行
操作“重命名文件”
基本上只是将文件路径从加载目录更改为归档目录

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


我不能一步完成这两项任务吗<是的,这是可能的。您需要编写脚本

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

命名空间:
使用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);
截图:


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

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

命名空间:
使用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);
截图:


thx-有时间的时候,我会尽量像你说的那样。目前正在努力解决工作中的其他一些问题^^^是的,当然。给我贴上标签,以防被卡住。:)thx-我会尽量像你说的那样,等我有时间的时候。目前正在努力解决工作中的其他一些问题^^^是的,当然。给我贴上标签,以防被卡住。:)