3
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

1

1 Answer 1

2

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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.