Reputation: 896
I'm trying to identify whether the content inside a fileinfo object is a directory and if not I need to add them in a stack. I'm trying with the below code but getting the subjected error in the "IF condition" not sure how to proceed from here. Any help is much appreciated.
public void Main()
{
// below (dts.var[]) is an object value coming from SSIS storing the fileinfo details in object format {feel free to include a fileInfo object that has file/directory details from any local path}
var fileinfo = Dts.Variables["User::SharePointListOfFiles"].Value;
List<String> OutputFileNames;
string outputresultnames = "";
int directory = 0;
foreach (object element in (fileinfo as IEnumerable ?? Enumerable.Empty<object>()))
{
var type = element.GetType();
var props = type.GetProperties();
foreach (var prop in props)
{
if ( prop.Attributes.HasFlag(FileAttributes.Directory))
{
directory = 1;
}
}
if (directory == 0)
{
object result = props.First().GetValue(element, null);
outputresultnames = (string)result;
OutputFileNames.Add(outputresultnames);
}
}
}
Upvotes: 0
Views: 302