locked
Directory variable problem RRS feed

  • Question

  • Hi,

    I have a for loop container with a File System Task that is used to move all files that start with inv (*inv).

    I have a string variable where I specify the directory path of the files' source and a variable for the destination.

    I get an error that states the directory cannot be found and hence the task fails. The thing is...that directory does exist and all the permissions are set...when I hard code the directory in by setting it in the designer and not mapping it to the variable in the expression, it works!!?

    It won't allow me to use the directory path as a string variable. That means I cannot change it when i deploy...

    I have also looked at a friends' project who uses the exact same work flow and components and we cannot see a difference. His works and mine don't even though he uses variables the same way mine is used for the directory.

    We are both stumped what the problem could be...I am vouching on a patch or update that I might not have but I'm not sure.

    Any assistance welcome

    Thanks
    Michael
    Thursday, April 12, 2007 1:07 PM

Answers

  • Hi there,

    I have recreated the package from scratch. Did everything the same as before and now it is picking the variables up and it's working fine now.

    Something must have gone corrupted.

    Regards
    Wednesday, April 18, 2007 8:18 AM

All replies

  • hi,

     

    just a wild guess. is the variable in the right scope.

     

    thanks,

    joey

    Thursday, April 12, 2007 1:17 PM
  • Make sure you set DelayValidation to True on that task.

    Also, the default value of that variable should point to a valid path -- even if it will be changed at run time.
    Thursday, April 12, 2007 1:20 PM
  • Hi,

    The scope of the variable is in my project. I have also a valid path as the default value and tried setting the DelayValidation to true but to no avail...still get the message:
    "
    Warning: The For Each File enumerator is empty. The For Each File enumerator did not find any files that matched the file pattern, or the specified directory was empty. "

    This is not an empty directory
    I will now try loading a service pack
    Friday, April 13, 2007 5:19 AM
  • hi,

    try to use the file pattern inv*.* and make sure there are files there that starts with inv

     

    if there are no other files in the directory except those that begins with inv you can use the file system task to copy or move the entire directory rather than iterating on each of the individual files

     

    thanks,

    joey

    Friday, April 13, 2007 7:38 AM
  • Hi,

    Thanks for the reply.
    I have tried virtually all formats of the filter string that one can think of and its safe to say that it's definitely not that. *.* doesn't even work. I can't copy the entire directory since I need to, at a later stage, handle different files with a different plan/task.

    The thing is that the variable does pass the directory through since it says that it cant see for example c:\temp. Now that directory is specified in a variable so it does use the variable properly otherwise the message would not have seen c:\temp.

    I have applied the visual studio team suit service pack which contained certain fixes for ssis hopefully.

    I'll get back shortly
    Friday, April 13, 2007 9:19 AM
  • Nope, no luck in the service pack fixing it.

    I wish I knew what was going on

    I have a string variable that is used by the for-each loop to get the directory and another string variavle to store the collection of files found which I refer to as my source in the task itself since the for loop stores the collection values of the files found into this variable.

    It works on a colleagues' machine but not on mine...
    Friday, April 13, 2007 10:03 AM
  • Have you set a breakpoint on the foreach loop container to verify the variable containing the full path is correct?  (For instance, you aren't missing a slash between the directory and the file parts?)
    Friday, April 13, 2007 12:08 PM
  • You mention "Expressions" in an earlier post, but on the off-chance that terminology is somewhat confused, I tried to recreate your problem by doing something that I have done in the past.

    You didn't perhaps put your variable name (e.g., @[User:: directoryVar]) in the Folder text box in the Enumerator Configuration section, did you? 

    I get the same error message you did when I do that rather than putting my it as an Expression in the Directory expression beneath the scrollable Foreach Loop Editor section within the Foreach Loop Editor.  (As I'm explaining this I'm realizing the poor labeling throughout this tool.)

    Another possibility could be that you created two variables to hold your directory string with different scopes.  I've been burned by creating one with the wrong scope and then creating it with the right scope only to have my component accessing the incorrectly-scoped one.
    Friday, April 13, 2007 3:29 PM
  • Hi,

    Thanks for the reply.

    I have put my directory variable in the scrollable enumerator section under Directory as it is suppose to be.

    I am now completely at a loss for words. I have declared another string variable. I gave it the correct path and that variable works. It picks up the files and moves them.

    The thing is that these 2 variables have exactly the same paths...they are the same but the one works and the other doesn't. They are both in the same scope. The funny thing is I changed the newly created variable to a different scope and then changed it back to the same scope again.

    I can only make the assumption that it might be a environment 'synchronization' bug, where if you change something and that it doesn't correctly update somewhere else behind the scenes like in an xml file somewhere. Hell I don't know but it can be a bit of a problem.

    Monday, April 16, 2007 6:27 AM
  • Hi there,

    I have recreated the package from scratch. Did everything the same as before and now it is picking the variables up and it's working fine now.

    Something must have gone corrupted.

    Regards
    Wednesday, April 18, 2007 8:18 AM
  • I know this thread is very old but in case people stumble across it like I did I wanted to offer something I found.  I had setup a SQL table that had rows containing the input folder paths and filespecs I wanted to point my SSIS package at.  Simple table (column 1 = Path, column 2 = file spec).  I was using a Foreach file loop container and put that inside a foreach loop container (ADO.NET) that was reading rows from my table and putting the filepath and filespec into variables.

    Everything seemed setup correctly but I kept getting the message saying the foreach file enumerator was empty and nothing would process.  I knew this wasn't the case.  Hours of testing revealed that SSIS was not trimming the extra spaces off the file paths or file specs as it read them from the table.  That caused the foreach file enumerator to find nothing.  I wrote a quick script and put it in my foreach record loop but before my foreach file loop.  All that script did was trim all the variables.  That worked.  If you write an app in Visual Studio that will read the same table and look for files, the compiler will ignore the extra spaces and it works.  That's what was throwing me off.  Anyway, if you're stuck with this type of problem this is just another thing to try.  Good luck.

    Thursday, May 10, 2012 7:28 PM