c# - SSIS脚本任务检查文件是否存在于文件夹中

标签 c# file ssis file-exists

我想检查文件是否存在于 SSIS 的特定文件夹中。我怎样才能做到这一点?

最佳答案

变量:

文件夹 - 字符串 - C::\Temp\

文件 - 字符串 - 1.txt

fileExists - bool 值 - 假

public void Main()
{
    string folder = Dts.Variables["User::folder"].Value.ToString();     //@"C:\temp\";
    string file = Dts.Variables["User::file"].Value.ToString();         //"a.txt";
    string fullPath = string.Format(@"{0}\{1}", folder, file);

    Dts.Variables["User::fileExists"].Value = File.Exists(fullPath);

    Dts.TaskResult = (int)ScriptResults.Success;
}

关于c# - SSIS脚本任务检查文件是否存在于文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17568554/

相关文章:

c# - 获取用我的应用程序打开的文件的路径+文件名

java - 如何存储文件字节并稍后再次创建该文件?

sql-server - 集成服务与原始 SQL (T-SQL)

c# - C# : need to convert Y2K string to date format and use it to populate variable 中的 SSIS 2008 脚本

c# - Entity Framework 代码第一列名称问题

c# - C# Azure Functions 中的 Task.Run

c# - 有很多渲染部分功能不好吗?

java - IO方法 block :

c# - 即使 Json 无效,如何解析第一个属性?

csv - 平面文件目标列数据类型验证