private void UpdateFolderBtn_Click(object sender, RoutedEventArgs e) { FileManager.jpegList.Clear(); FileManager.jpgList.Clear(); FileManager.mp3List.Clear(); FileManager.mp4List.Clear(); FileManager.pngList.Clear(); FolderViewBox.Items.Clear(); DirectoryInfo temporaryDirInfo = new DirectoryInfo(DirectoryPathTextBox.Text); FileManager.recursiveFileSearch(temporaryDirInfo); CreateListBoxItemsForFiles(); DatabaseHandler dbHandler = new DatabaseHandler(); Folder currentFolder = dbHandler.AddFolderToDatabase(temporaryDirInfo.Name, DirectoryPathTextBox.Text); foreach (FileInfo file in temporaryDirInfo.GetFiles()) { dbHandler.AddFilesToDatabase(file.Name, file.FullName, currentFolder); } CreateListBoxItemForFolders(); }