I have to create a Windows service which monitors a specified folder for new files and processes it and moves it to other location.
I started with using FileSyste
You could use Directory.GetFiles()
:
using System.IO;
var fileList = new List();
foreach (var file in Directory.GetFiles(@"c:\", "*", SearchOption.AllDirectories))
{
if (!fileList.Contains(file))
{
fileList.Add(file);
//do something
}
}
Note this only checks for new files not changed files, if you need that use FileInfo