stevegray
4Penny.net
Points: 55409

4/2/2012 10:45:47 AM

Loop through files in a folder

* This article, and all our great .NET Development documentation, Is available on the .NET Development menu

In writing Dynamics integrations, I'm frequently asked to read a directory of files and process them somehow. Sometimes they're XML, sometimes text. 

This piece of code is the main loop for that task. It's not ground breaking or brilliant; but it saves me 30-60 minutes of coding to have it ready so that I can copy and paste into an app. 

The basic logic is this:

Create 'done' and 'error' folders to move the files into after processing

Loop

Process the file

Move the file to 'done'

Trap errors

Move the file to 'error

Handle the error 

4Penny.net
Version: Unknown or N/A
Section: .NET Development
Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
3