/// <summary> /// Will check if the given covers are in use. /// </summary> /// <param name="covers"></param> /// <param name="coversFromDb"></param> /// <returns></returns> private int CheckCoversToDelete(string[] covers, List <string> coversFromDb) { int deleted = 0; foreach (string file in covers) { bool coverFileIsUsed = false; foreach (string cover in coversFromDb) { if (Path.LastSegment(file) == cover) { coverFileIsUsed = true; } } if (!coverFileIsUsed) { try { File.Delete(file); deleted++; } catch (Exception) { } } } return(deleted); }
/* * ============================================ * Public * ============================================ */ #region Public /// <summary> /// Get the files, store them in the list and display them in the view. /// </summary> private void GetFileList() { string path = Path.DbBackupFolder; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string[] files = Directory.GetFiles(path); foreach (string file in files) { this.files.Add(new File(file)); this.FilesList.Items.Add(Path.LastSegment(this.files[this.files.Count - 1].Path).Replace("_.db", "").Replace("hiedb_", "")); } }