RegExFileFilter

Sep 18, 2014 at 10:02 PM
Edited Sep 18, 2014 at 10:59 PM
I am having some problems using the RegExFileFilter. I am using the 2008 version of TaskUnZip (couldn't get the 2012 version to load with SQL 2008 R2). I am using variables that are declared with a scope of package. I have those variables in a "Watch" on VS 2012 and they are loading correctly with the values (from a SQL stored procedure). I am using expressions to load the TaskUnZip for FolderSource, FolderDestination, and RegExFileFilter. I have "Delay Validation" set to True because the values for the expressions have to be loaded dynamically.

I have the FolderSource and FolderDestination set to: @[User::TempFilePath]. I have tried it as a setting in the property and as an expression setting thatsame property value. I have "RecurseSubFolder" set to False as I only want files that match the RegExFileFilter. Your "documentation" mentions that the RegExFileFilter follows the .NET version. I have it set to @[User::FileName] + "." This should return all, and only, files that match the entire filename, but have different extensions. "TypeOperation" is set to "Compress". During runtime, the RegExFileFilter shows . which is what it would be set to before the variables load. That nevers changes. I set a breakpoint on every event allowed by VS2012 for TaskUnZip and stepped through them all. I put the TaskUnZip in the watch list, but the RegExFileFilter, FolderSource, and FolderDestination are not available to view under it. All of my variables are and they all show the proper value.

The Output during runtime shows the following:

Information: 0x1 at TaskUnZip, UnZip SSIS: Start 1
Information: 0x1 at TaskUnZip, UnZip SSIS: Start process file: 'C:\temp\HIP\AL245.zip'.
Error: 0xC0024104 at TaskUnZip: The Execute method on the task returned error code 0x80070020 (The process cannot access the file 'C:\temp\HIP\AL245.zip' because it is being used by another process.). The Execute method must succeed, and indicate the result using an "out" parameter.
Task failed: TaskUnZip

The zip file is being newly created and no other programs have it open or even the directory open. The zip file is actually valid with the correct files in it, but the task is failing with that error. I tried this with all breakpoints removed and get the same problem.

So, what am I missing?
Sep 19, 2014 at 12:32 PM
You know how sleeping on something brings a big "aha" moment? Well, that happened last night. Something important to remember here. If the Source directory and the Destination Directory are the same AND the RegExFileFilter is looking for files where ONLY the extension is different, you are trying to include the ZIP file you are creating in the ZIP file you are creating. :-) Example: FolderSource and FolderDestination are both set to "C:\temp". The RegExFileFilter is set to "123.*". The files in the directory are 123.txt, 123.rpt, 321.txt, and 321.rpt. And the FileZip is set to "123.zip". You might think it will find 123.txt and 123.rpt. BUT, the ZIP file is apparently created first, thus when the filter is applied, you also have 123.zip in the directory. Since you are trying to open the zip file to read it into the zip file that you have open, the error shown above is created. Lesson: Either do not have the FolderSource and FolderDestination set to the same location or do not have the FileZip match the RegExFileFilter setting!
Marked as answer by JRWolf1959 on 9/19/2014 at 4:33 AM
Coordinator
Sep 20, 2014 at 9:40 AM
yes! good conclusion :)

thanks for sharing your solution.

ciao
p