public static string GetProperty(string filePath, PropertiesEnum property)
        {
            var folder     = new Shell32.Shell().NameSpace(Path.GetDirectoryName(filePath));
            var item       = folder.ParseName(Path.GetFileName(filePath));
            var fixed_Data = RemoveMiscChar(folder.GetDetailsOf(item, (int)property));

            return(fixed_Data);
        }
        public static TimeSpan GetTimeSpanProperty(string filePath, PropertiesEnum property)
        {
            var folder     = new Shell32.Shell().NameSpace(Path.GetDirectoryName(filePath));
            var item       = folder.ParseName(Path.GetFileName(filePath));
            var fixed_Data = RemoveMiscChar(folder.GetDetailsOf(item, (int)property));

            if (!string.IsNullOrWhiteSpace(fixed_Data))
            {
                return(TimeSpan.Parse(fixed_Data));
            }
            else
            {
                return(new TimeSpan());
            }
        }
Ejemplo n.º 3
0
        private static IEnumerable<Song> GetSongsInFolder(string current)
        {
            var shellFolder = new Shell32.Shell().NameSpace(current);

            Func<string, bool> fileFilter =
                name => name.EndsWith("mp3", StringComparison.CurrentCultureIgnoreCase) || name.EndsWith("wma", StringComparison.CurrentCultureIgnoreCase);

            var albumArt = GetAlbumArtFile(current);

            return Directory.EnumerateFiles(current)
                .Where(fileFilter)
                .Select(Path.GetFileName)
                .Select(shellFolder.ParseName)
                .Select(shellFile => new Song
                                            {
                                                Path = Path.Combine(current, shellFolder.GetDetailsOf(shellFile, 0)),
                                                AlbumArtPath = albumArt,
                                                Artist = GetArtist(shellFolder, shellFile),
                                                Title = GetTitle(shellFolder, shellFile),
                                                Album = shellFolder.GetDetailsOf(shellFile, 14),
                                                Size = ExtensionMethods.ToFileSize(shellFolder.GetDetailsOf(shellFile, 1)),
                                                Rating = shellFolder.GetDetailsOf(shellFile, 19),
                                                Genre = shellFolder.GetDetailsOf(shellFile, 16),
                                                PrimaryGenre = GetPrimaryGenre(shellFolder.GetDetailsOf(shellFile, 16)),
                                                Duration = ExtensionMethods.ToTimeSpan(shellFolder.GetDetailsOf(shellFile, 27)),
                                                DateCreated = ExtensionMethods.ToDateTime(shellFolder.GetDetailsOf(shellFile, 4)),
                                            });
        }