/// <summary> /// Starts a File Explorer process and navigates to foldersListView's selected item's folder. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void foldersListViewCM_RevealInExplorer_Click(object sender, RoutedEventArgs e) { // Can't browse to less than or more than one folder if (foldersListView.SelectedItems == null || foldersListView.SelectedItems.Count > 1) { return; } FolderStatisticsModel selectedItem = (FolderStatisticsModel)foldersListView.SelectedItem; if (selectedItem == null) { return; } if (!Directory.Exists(selectedItem.AbsolutePath)) { return; } // Launch File Explorer and select the file corresponding to selectedItem ProcessStartInfo startInfo = new ProcessStartInfo { Arguments = selectedItem.AbsolutePath /* command-line arguments */, FileName = "explorer.exe" }; Process.Start(startInfo); }
/// <summary> /// Returns a List containing each unique FileAbsolutePath value for records in the database whose /// ParentDirAbsolutePath value matches @directory's AbsolutePath property. /// </summary> /// <param name="directory"></param> /// <returns></returns> public static List <string> GetUniqueFilePathsInDirectory(FolderStatisticsModel directory) { // Safely open a connection to our database using (IDbConnection dbConnection = new SQLiteConnection(LoadConnectionString())) { // Query the database string query = "SELECT DISTINCT FileAbsolutePath FROM FileTimestamp WHERE ParentDirAbsolutePath = '" + directory.AbsolutePath + "'"; var output = dbConnection.Query <string>(query, new DynamicParameters()); // Convert output to a List and return it return(new List <string>(output)); } }