使用 SSIS 复制目录 [英] Copy Directories with SSIS

查看:26
本文介绍了使用 SSIS 复制目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2012 中使用 SSIS.

I am using SSIS with Visual Studio 2012.

我正在使用变量来创建文件夹和文件夹内的文件夹.

I am using variables to make folders and folders within folders.

父文件夹是静态的 VarFolderPath = c:\Source\test\

The parent folder is static VarFolderPath = c:\Source\test\

其中的第一个子目录基于 yyyymm 是动态的.我使用以下表达式将此文件夹存储在变量 VarFolderName 中.

the first subdirectory within it is dynamic based on yyyymm. I use the following expression to make this folder stores in the variable VarFolderName.

@[User::VarFolderPath]+RIGHT("0" + (DT_STR, 4, 1252) DATEPART("yy" , GETDATE()), 4) +  (DT_STR, 2, 1252) DATEPART("mm" , GETDATE())

VarFolderName 中,我创建了另外四个文件夹 CLI、Day3、INF、PRI.这就是全部工作

Within VarFolderName I then make four other folders CLI, Day3, INF, PRI. That is all working

然后我想复制 Day3 文件夹中的 CLI、INF 和 PRI.我想要两个版本的 CLI,INF 和 PRI.一个直接在 VarFolderName 中,另一个在 Day3 中.我可以创建更多变量来完成此操作,但由于我已经创建了目录,因此我希望复制它们.但是,使用文件系统任务 > 复制目录不会复制文件夹,而是复制文件夹内的所有文件.

I then want to copy CLI, INF, and PRI within the Day3 folder. I want two versions of CLI, INF and PRI. Oned irectly in VarFolderName, and another in Day3. I could make more variables to accomplish this, but since I already made the directories I was hoping to copy them. However using File System Task > Copy Directory does not copy folders, it copies all files within folders.

因此,除了添加三个额外的变量之外,还有一种方法可以利用我已经创建的目录(CLI、INF、PRI)并将它们的副本放在 Day3 中,如下面的数字 5、6、7 所示.

Thus other than adding three additional variables is there a way to leverage the directories I have already made (CLI,INF, PRI) and place copies of them in Day3 shown as numbers 5,6,7 below.

  • 最终目标

  • The end goal

  1. VarFolderName\CLI
  2. VarFolderName\INF
  3. VarFolderName\PRI
  4. VarFolderName\Day3

  1. VarFolderName\CLI
  2. VarFolderName\INF
  3. VarFolderName\PRI
  4. VarFolderName\Day3

VarFolderName\Day3\CLI

VarFolderName\Day3\CLI

推荐答案

文件系统任务在 SSIS 中非常有限——它实际上是用于最基本的操作.即使您拥有到目前为止,与您在脚本任务中可以做的事情相比,它也变得有点复杂.请查看此代码示例并尝试用 c# 或 vb 重写:

The file system task is pretty limited in SSIS - it is really intended for the most basic operations. Even with what you have so far, it is getting a bit complicated compared to what you could do in a script task. Please check out this code example and try rewriting this in c# or vb:

http://msdn.microsoft.com/en-us/library/bb762914(v=vs.110).aspx

这篇关于使用 SSIS 复制目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆