SphereStudio.Plugins.SoundPicker.UpdateTrackList C# (CSharp) Method

UpdateTrackList() private method

Fills out the list with the music and sound files in your game path.
private UpdateTrackList ( ) : void
return void
        private void UpdateTrackList()
        {
            string gamePath = PluginManager.Core.Project.RootPath;
            if (string.IsNullOrEmpty(gamePath))
                return;

            // if the project is set to build out-of-source, avoid enumerating the build directory.
            string buildPath = Path.Combine(gamePath, PluginManager.Core.Project.BuildPath)
                .Replace('/', Path.DirectorySeparatorChar)
                .Replace('\\', Path.DirectorySeparatorChar);
            if (buildPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
                buildPath = buildPath.Substring(0, buildPath.Length - 1);
            bool haveBuildDir = Path.GetFullPath(buildPath) != Path.GetFullPath(gamePath);

            trackList.BeginUpdate();
            foreach (string filterInfo in _fileTypes)
            {
                string[] parsedFilter = filterInfo.Split(':');
                string searchFilter = parsedFilter[0];
                string groupName = parsedFilter[1];

                trackList.Groups.Add(groupName, groupName);

                DirectoryInfo dirInfo = new DirectoryInfo(gamePath);
                FileInfo[] fileInfos = dirInfo.GetFiles(searchFilter, SearchOption.AllDirectories);

                foreach (FileInfo fi in from x in fileInfos
                                        where !x.FullName.StartsWith(buildPath) || !haveBuildDir
                                        orderby x.Name select x)
                {
                    var relativePath = fi.FullName
                        .Replace(gamePath + Path.DirectorySeparatorChar, string.Empty)
                        .Replace(Path.DirectorySeparatorChar, '/');
                    ListViewItem listItem = trackList.Items.Add(Path.GetFileNameWithoutExtension(fi.FullName), 0);
                    listItem.Tag = (object)fi.FullName;
                    listItem.Group = trackList.Groups[groupName];
                    listItem.SubItems.Add(relativePath);
                }
            }
            trackList.EndUpdate();
        }