private void ParsePath(string path) { ArtistName = String.Empty; AlbumTitle = String.Empty; TrackTitle = String.Empty; TrackNumber = 0; Match match; SafeUri uri = new SafeUri(path); string filename = path; if (uri.IsLocalPath) { filename = uri.AbsolutePath; } match = Regex.Match(filename, @"(\d+)\.? *(.*)$"); if (match.Success) { TrackNumber = Convert.ToInt32(match.Groups[1].ToString()); filename = match.Groups[2].ToString().Trim(); } // Artist - Album - Title match = Regex.Match(filename, @"\s*(.*)-\s*(.*)-\s*(.*)$"); if (match.Success) { ArtistName = match.Groups[1].ToString(); AlbumTitle = match.Groups[2].ToString(); TrackTitle = match.Groups[3].ToString(); } else { // Artist - Title match = Regex.Match(filename, @"\s*(.*)-\s*(.*)$"); if (match.Success) { ArtistName = match.Groups[1].ToString(); TrackTitle = match.Groups[2].ToString(); } else { // Title TrackTitle = filename; } } while (!String.IsNullOrEmpty(path)) { filename = Path.GetFileName(path); path = Path.GetDirectoryName(path); if (AlbumTitle == String.Empty) { AlbumTitle = filename; continue; } if (ArtistName == String.Empty) { ArtistName = filename; continue; } break; } ArtistName = ArtistName.Trim(); AlbumTitle = AlbumTitle.Trim(); TrackTitle = TrackTitle.Trim(); if (ArtistName.Length == 0) { ArtistName = /*"Unknown Artist"*/ null; } if (AlbumTitle.Length == 0) { AlbumTitle = /*"Unknown Album"*/ null; } if (TrackTitle.Length == 0) { TrackTitle = /*"Unknown Title"*/ null; } }