Exemplo n.º 1
0
        /// <summary>
        /// Points the Equalizer APO configuration file to the specified named file.
        /// If null, the file it points to is the name found by <see cref="File.GetEqualizerFilename"/>().
        /// If <see cref="NO_FILTERS"/>, the configuration is set not to point to any file.
        /// </summary>
        /// <param name="equalizerFilename"></param>
        private void PointConfig(String equalizerFilename = null)
        {
            // get the equalizer file name
            if (CurrentFile == null && equalizerFilename == null)
            {
                return;
            }
            if (!applyEqualizer)
            {
                return;
            }
            if (equalizerFilename == null)
            {
                equalizerFilename = CurrentFile.GetEqualizerFilename();
            }
            String configPath = File.GetEqualizerAPOPath() + "config\\config.txt";

            // check for none.txt filenames
            if (equalizerFilename == NO_FILTERS)
            {
                File.WriteAllLines(configPath, new string[] { "" });
            }

            // check that the config file exists and is a file, not a directory
            if (!System.IO.File.Exists(configPath) ||
                (System.IO.File.GetAttributes(configPath) & FileAttributes.Directory) == FileAttributes.Directory)
            {
                throw new FileNotFoundException(
                          String.Format("File {0} not found or is directory.", configPath),
                          configPath);
            }

            // write the include to the config file
            File.WriteAllLines(configPath, new string[] { "Include: " + equalizerFilename });
        }