/// <summary> /// Default constructor /// </summary> private KeyCollection() { keys = new ArrayList(); // Get a list of the key files for the NWN install and add the files // to a StringCollection, forcing the names to lower case. string[] filesArray = Directory.GetFiles(NWN.NWNInfo.InstallPath, "*.key"); StringCollection files = new StringCollection(); foreach (string file in filesArray) files.Add(Path.GetFileName(file).ToLower()); // We need to do the files in a certain order, as we want to check the xp's in // reverse order, then the main game last. ProcessFile(files, "xp2patch.key"); ProcessFile(files, "xp2.key"); ProcessFile(files, "xp1patch.key"); ProcessFile(files, "xp1.key"); // Now process whatever is left. foreach (string file in files) { Key key = new Key(file); keys.Add(key); } }
/// <summary> /// Checks to see if the string collection contains the key file, and if it does /// loads it and removes it from the collection. /// </summary> /// <param name="files">The list of files</param> /// <param name="file">The key file to process</param> private void ProcessFile(StringCollection files, string file) { if (files.Contains(file)) { // Create the key, add it to our collection, and remove the // file from the list as we've loaded it. Key key = new Key(file); keys.Add(key); files.Remove(file); } }