在 SSIS 中压缩文件夹的内容 [英] Zip the contents of a folder in SSIS

查看:46
本文介绍了在 SSIS 中压缩文件夹的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 SSIS 中压缩文件夹的内容,源文件夹中有文件和文件夹,我需要单独压缩它们.我可以将文件压缩,我的问题是文件夹.

I am trying to zip the contents of a Folder in SSIS, there are files and folders in the source folder and I need to zip them all individually. I can get the files to zip fine my problem is the folders.

我必须使用 7.zip 来创建压缩包.

I have to use 7.zip to create the zipped packages.

谁能给我指点一个好的教程.我无法实现我发现的任何示例.

Can anyone point me to a good tutorial. I haven't been able to implement any of the samples that I have found.

谢谢

推荐答案

这就是我配置它的方式.

This is how I have configured it.

它易于配置,但诀窍在于构建参数.尽管您在屏幕截图中看到 Arguments 是静态的,但它实际上来自一个变量,并且该变量是在 Execute Process Task 的Arguments 表达式中设置的.

Its easy to configure but the trick is in constructing the Arguments. Though you see the Arguments as static in the screenshot, its actually coming from a variable and that variable is set in the Arguments expression of Execute Process Task.

我认为您将在 For Each File Ennumerator 中执行此执行进程任务,并选中 遍历子文件夹.

I presume you will have this Execute Process task in a For Each File Ennumerator with Traverse SubFolders checked.

一旦你有了这个基本的设置,你需要做的就是构建参数来进行压缩,你想要的方式.找到所有命令行参数的好地方是这里.

Once you have this basic setup in place, all you need to do is work on building the arguments to do the zipping, how you want them. A good place to find all the command line arguments is here.

最后,我遇到的唯一问题是没有在 7zip 的命令行参数中提供工作目录.该包曾经在我的开发环境中运行良好,但在通过 SQL 作业在服务器上运行时曾经失败.这是因为 7zip 无权访问 SQL Server 上的Temp"文件夹,它默认用作工作目录".我通过使用 -ws 开关在命令行参数的末尾指定工作目录"来解​​决这个问题:

Finally, the only issue I ran into was not providing a working directory in the command line arguments for 7zip. The package used to run fine on my dev environment but used to fail when running on the server via a SQL job. This was because 7zip didn't have access to the 'Temp' folder on the SQL Server, which it uses by default as the 'working directory'. I got round this problem by specifying the 'working directory as follows at the end of the command line arguments, using the -ws switch:

例如:

a -t7z DestinationFile.7z 源文件 -wS:YourTempDirectoryToWhichTheSQLAgentHasRights

a -t7z DestinationFile.7z SourceFile -wS:YourTempDirectoryToWhichTheSQLAgentHasRights

这篇关于在 SSIS 中压缩文件夹的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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