SSIS使用C#

问题描述

我正在研究一个相当简单的SSIS包,该包使用ODBC Source从DB2读取并将其带到平面文件目的地。但是我需要生成文件为UTF-8(不带BOM),而不是ANSI,因为它是SSIS自动生成的。最适合我的是下面的代码,但它将其转换为UTF-8 BOM,客户端告诉我带有BOM的文件不适用于他。有什么办法可以使文件为UTF-8?

string srcFilename = Dts.Variables["User::FFDestPath"].Value.ToString();
string text = File.ReadAllText(srcFilename);
File.WriteallText(srcFilename,text,System.Text.Encoding.UTF8);
Encoding utf8WithoutBom = new UTF8Encoding(false);

编辑:

enter image description here

enter image description here

解决方法

要在SSIS中进行本地编写,请在平面文件连接管理器中将代码页指定为65001(UTF-8)。

enter image description here

平面文件目标写入文件时,没有写入BOM。

enter image description here