How do I pick XML files created everyday within a folder created at 4:00 PM everyday Mon-Fri, within the folder is an XML file with name convention exported 4:03PM which will need to be loaded to SQL

Importing XML files created everyday within a folder and subfolder created at 4:00 PM everyday Mon-Fri, within the folder is an XML file  with name convention exported 4:03PM which will need to be loaded to SQL table

 folder path : Z:\background-processarea\Outbound
 Subfolders Paths:
                                      Name                                                            DateModified                               Type
Z:\background-processarea\Outbound\BGP_1413656            1/8/2018 4:00PM                     File folder      
            Xx exported                                                                           1/8/2018 4:03PM                       XML
            Xx recorder-BGP-out-210307                                             1/8/2018 4:00PM                       XML  
Z:\background-processarea\Outbound\BGP_1412472            1/5/2018 7:00PM                     File folder
          Xx exported                                                                           1/8/2018 4:03PM                         XML
          Xx recorder-BGP-out-207020                                             1/8/2018 4:00PM                         XML  
Z:\background-processarea\Outbound\BGP_1412471            1/5/2018 4:00PM                     File folder
            Xx exported                                                                           1/8/2018 4:03PM                       XML
            Xx recorder-BGP-out-206848                                             1/8/2018 4:00PM                       XML  
Z:\background-processarea\Outbound\BGP_1412470            1/5/2018 4:00PM                     File folder
           Xx exported                                                                            1/8/2018 4:03PM                        XML
          Xx recorder-BGP-out-210307                                               1/8/2018 4:00PM                        XML  

How could you get a for each file enumerator  & Script Task to pick only files created at 4:00 PM with XML files created at 4:03PM (exported)  within the folder & load it to SQL table everyday.

I know it can be done with an expression in the enumerator, I just cant figure it out
Larry oklaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
I'm not sure I entirely understand your question.  But you can get a list of all files in a directory, and then loop over the files to find the ones created at a specific time.

//get a list of all files in the directory
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(var file in fileEntries)
{
    //get date time stamp
     DateTime dt = File.GetLastWriteTime(file);
    if(dt.ToString("HH:mm") == "16:00")
    {
          //do something
     }
}

Open in new window

From:
https://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetime(v=vs.110).aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zephyr_hex (Megan)DeveloperCommented:
Did this answer your question?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.