简体   繁体   中英

C# script task in SSIS

try
{
    DirectoryInfo d = new DirectoryInfo(@"\\filepath\format");
    foreach (var f in d.GetFiles("*.csv"))
    {
        File.Copy(f.FullName.ToString(), @"filepath\out\", true);
    };

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

When i am trying the above script, i am getting the below error message

File.Copy error - C# - IOException The filename, directory name, or volume label syntax is incorrect

You need to copy to a file rather than a folder. The following will work:

try
{
    DirectoryInfo d = new DirectoryInfo(@"\\filepath\format");
    foreach (var f in d.GetFiles("*.csv"))
    {
        File.Copy(f.FullName.ToString(), @"filepath\out\" + Path.GetFileName(f.FullName), true);
    };

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM