SSIS Script Task Copy Files with Wildcards
Hi All - In a C# Script Task want to copy one or several files based on a value assigned to a param. I have everything working except the copy. (Seems like it should be the easy part!) Can someone tell me what is wrong with the code below? TIA - Gimcrack File.Copy(@"\\dev01\E$\Data\Proc\Opt\FF1_*.*", @"\\dev01\E$\Data\Proc\Opt test\", true);
November 14th, 2010 10:17am

string[] files = System.IO.Directory.GetFiles(@"\\dev01\E$\Data\Proc\Opt", @"FF1_*.*"); foreach (string file in files) { System.IO.File.Copy(file, @"\\dev01\E$\Data\Proc\Opt test\" + System.IO.Path.GetFileName(file), true); } Based on code from http://www.xtremedotnettalk.com/showthread.php?t=86006 The documentation for File.Copy indicates that the copy is one file to a file. I don't think that it can handle wildcard copies. Russel Loski, MCT
Free Windows Admin Tool Kit Click here and download it now
November 14th, 2010 11:12am

File.Copy does not accept wildcards. You can iterate over the files like Russ posted, but you can do that very easily without any coding (the goodness of SSIS is in not coding) by employing a ForEach loop + a File System Task to copy the needed files. A short how-to is below from Sudeep's blog: http://beyondrelational.com/blogs/sudeep/archive/2010/09/29/ssis-dynamically-set-file-mask-filespec.aspx by adapting this approach your package will become also more flexible.Arthur My Blog
November 14th, 2010 4:05pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics