/// <summary>Safe way to cleanup the temp directory. Should be called via scheduled task.</summary> public static void TempCleanup() { try { string dir = AppPath.TempDir(); if (!Directory.Exists(dir)) { return; } FileInfo fi; DateTime dtOld = DateTime.Now.Subtract(new TimeSpan(0, 5, 0, 0)); var files = Directory.EnumerateFiles(dir); foreach (string file in files) { fi = new FileInfo(file); if (fi != null && fi.LastWriteTime < dtOld) { AppPath.Delete(file); } } } catch (Exception exc) { exc.Dump(); } }
/// <summary>Safe way to cleanup the temp directory. Should be called via scheduled task.</summary> public static void TempCleanup() { try { string dir = AppPath.TempDir(); if (!Directory.Exists(dir)) { return; } FileInfo fi; DateTime dtOld = DateTime.Now.Subtract(new TimeSpan(0, 5, 0, 0)); var files = Directory.EnumerateFiles(dir); foreach (string file in files) { //if (file.EndsWith(".resx", StringComparison.OrdinalIgnoreCase)) // continue; // MultiUploader Temp-Dateien werden nach 5 Stunden automatisch durch die Komponente gelöscht fi = new FileInfo(file); if (fi != null && fi.LastWriteTime < dtOld) { AppPath.Delete(file); } } } catch (Exception exc) { exc.Dump(); } }