<p>There are some cool and exciting features in .NET 3.5/C# 3.0, and with those features comes some darn interesting ways to write the exact same line of code.</p>

<p>Using the above stated tool set (and by extension .NET 2.0 stuff), what are the different ways the below code snippet could reasonably be rewritten? </p>

<pre><code>        string uploadDirectory = "c:\\some\\path\\";
        if (Directory.Exists(uploadDirectory)) {
            string[] files = Directory.GetFiles(uploadDirectory);
            foreach (string filename in files) {
                if (File.GetLastWriteTime(filename).AddHours(12) &lt; DateTime.Now) {
                    File.Delete(filename);
                }
            }
        }
</code></pre>

Lambda:
```
```
if (Directory.Exists(uploadDirectory)) 
  Directory.GetFiles(uploadDirectory)
    .Where(f => File.GetLastWriteTime(file) < DateTime.Now.AddHours(-12))
    .Each(f => File.Delete(f));
```
```
Edit: On 2nd thought, you can avoid the security lookups on each File access by using DirectoryInfo and FileInfo instead of the static File methods:
```
```
var di = new DirectoryInfo(uploadDirectory);
if (di.Exists()) {
   di.GetFiles()
     .Where(f => f.LastWriteTime < DateTime.Now.AddHours(-12))
     .Each(f=> f.Delete());
}
```
```
And for those missing their own Each method:
```
```
void Each<T>(this IEnumerable e, Action<T> action) {
  foreach (T t in e) {
    action(t);
  }
}
```
```
To make this really crazy, and fit the C# 3.0 theme, let's throw in an anonymous type:
```
```
di.GetFiles().Select(f => new() {
   Delete = f.LastWriteTime < DateTime.Now.AddHours(-12) ? f.Delete : () => { }
}).Delete();
```
```
But that just doesn't make any sense. ;)