CSharp examples for File IO:Directory
Clean Directory
using System.IO;/*from ww w. ja v a2s . c o m*/ using System.Web; using System.Linq; using System.Collections.Generic; using System; public class Main{ /** * Clean up a given directory. * @param directory The directory to clean. */ public static void CleanDirectory(string directory) { try { string[] tempFiles = Directory.GetFiles(directory); // Delete each file in the given directory. foreach (string tempFile in tempFiles) { File.Delete(tempFile); } } catch (Exception ex) { // TODO: Add handling code here. } } }