private static string GetArtist(Shell32.Folder shellFolder, Shell32.FolderItem shellFile) { if (!string.IsNullOrEmpty(shellFolder.GetDetailsOf(shellFile, AUTHOR))) return shellFolder.GetDetailsOf(shellFile, AUTHOR); if (!string.IsNullOrEmpty(shellFolder.GetDetailsOf(shellFile, ALBUM_ARTIST))) return shellFolder.GetDetailsOf(shellFile, ALBUM_ARTIST); return "Unknown Artist"; }
// Gets each video in the child folders private static void DirSearch(Shell32.Folder sDir) { // Goes through each folder foreach (Shell32.FolderItem2 item in sDir.Items()) { // Finds each file in folder string type = (string)item.ExtendedProperty("Type"); if (type.ToLower().Contains("folder")) { DirSearch(shell.NameSpace(sDir.GetDetailsOf(item, 180))); } else { if (type.ToLower().Contains("mp3")) { Songs w = new Songs((string)item.ExtendedProperty("Name"), sDir.GetDetailsOf(item, 21)); windowsSongs.Add(w); //Debug.WriteLine("Title: {0}\n Name: {1}\n Ext: {2}\n\n", sDir.GetDetailsOf(item, 21), (string)item.ExtendedProperty("Name"), (string)item.ExtendedProperty("Type")); } } } }
private void ProcessFile(Shell32.FolderItem file, Shell32.Folder objFolder) { Debug.WriteLine(" [Processing File " + file.Path + "]"); DataRow data = files.NewRow(); foreach (int id in ColumnListPerID) { if (id != 26) data[objFolder.GetDetailsOf(null, id).Replace("'", "_").Replace("’", "_")] = objFolder.GetDetailsOf(file, id); } if (string.IsNullOrEmpty(objFolder.GetDetailsOf(file, 26))) data[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")] = DBNull.Value; else data[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")] = int.Parse(objFolder.GetDetailsOf(file, 26)); if ((string) data[objFolder.GetDetailsOf(null, 21).Replace("'", "_").Replace("’", "_")] == "") data[objFolder.GetDetailsOf(null, 21).Replace("'", "_").Replace("’", "_")] = System.IO.Path.GetFileName(file.Path); data["URI"] = new Uri(file.Path); data["ID"] = files.Rows.Count + 1; files.Rows.Add(data); }
private static string GetTitle(Shell32.Folder shellFolder, Shell32.FolderItem shellFile) { if (!string.IsNullOrEmpty(shellFolder.GetDetailsOf(shellFile, TITLE))) return shellFolder.GetDetailsOf(shellFile, TITLE); // return the filename if there's no title return shellFolder.GetDetailsOf(shellFile, FILENAME); }