How to set Enumerator: Foreach From Variable Enumerator for Foreach Loop Container?
Hi,
I have a Foreach Loop Container, which is picking XML files from a folder. In collection of Foreach Loop Container, When I set Enumerator: Foreach File Enumerator and providing folder and file extention, It is working correctly.
but I don't want to hard code it, I want to provide Folder name by using variable so I set Enumerator: Foreach From Variable Enumerator and Selected a user created variable Filepath, but it is not working and throwing
Error: The type of the value being assigned to variable "User::FilePath" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Please help me out.
Thanks Shiven:)
February 26th, 2011 7:40am
Change the User::FilePath to object data type it will workNanda
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 7:48am
Hi Venkata,
Do you mean that I need to change Variable User::FilePath Data Type as Object? I tried by changing and it is throwing errors
1-Error: The object in the variable "User::V_FilePath" does not contain an enumerator.
2-Error: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80131509 "(null)". This occurs when the ForEach Enumerator cannot enumerate.Thanks Shiven:)
February 26th, 2011 7:59am
Two different ways:
1. Use an Expression to set Folder and/or Extension from a variable
2. read all files with Fullpath into a Recordset an loop throught that Recordset. In that case you have to set the Variable to Type Object and the Enumerator to "ADO Enumerator"
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 7:59am
Hi Christa,
Please can you tell me sample expression for this method.1. Use an Expression to set Folder and/or Extension from a variable
Suppose Variable Name is V_Filepath and Extension is *.XMLThanks Shiven:)
February 26th, 2011 8:17am
1: Select ForEach File Enumerator and in expressions select Directory and in expressions add @[User::V_FilePath] for foldername which to
get files and under Enumerator Configuration Folder: make it blank
2: Add another variable if you want to get the file name, Variable Mappings : select variable User::FileName and index 0
3: you can add script task in For Each File and read the FileName variable value for each file.
Nanda
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 8:25am
Open the ForEach Container
On the Collection-Tab go to Expression and set the Property "Directory" to your Variable
February 26th, 2011 8:27am
Hi Venkata,
1: Select ForEach File Enumerator and in expressions select Directory and in expressions add @[User::V_FilePath] for foldername which to
get files and under Enumerator Configuration Folder: make it blank
2: Add another variable if you want to get the file name, Variable Mappings : select variable User::FileName and index 0
It is Working.Thanks Shiven:)
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2011 8:32am