private void removeUnwantedFolders(string logFile) { string wrkSpaceDir = System.Web.Hosting.HostingEnvironment.MapPath("~") + "WorkSpace\\"; EventClient evClient = new EventClient(); string[] subdirs = System.IO.Directory.GetDirectories(wrkSpaceDir); foreach (string dir in subdirs) { int evFolder; string dirToCheck = dir.Substring(dir.LastIndexOf('\\')).Remove(0, 1); bool parse = int.TryParse(dirToCheck, out evFolder); if (!evClient.isEventExist(evFolder) || !parse) { emptyFolder(dir); System.IO.Directory.Delete(dir); } } evClient.Close(); System.IO.StreamWriter strWriter = new System.IO.StreamWriter(logFile, false); strWriter.WriteLine(DateTime.Now.ToString("yyyyMMdd")); strWriter.Close(); }