Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 487
Raja Sekhar Avatar asked Mar 25 '26 01:03

Raja Sekhar


1 Answers

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;
}
like image 66
Chris Mack Avatar answered Mar 27 '26 14:03

Chris Mack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!