Globals.RegistryAccess.AddRecentFile C# (CSharp) Method

AddRecentFile() public static method

Adds a file to the Halo 2 recently used list
public static AddRecentFile ( int pos, string fileName ) : void
pos int The position in which to add the fileName (0-9)
fileName string The location and name of the file
return void
        public static void AddRecentFile(int pos, string fileName)
        {
            int found = -1;
            int count = 0;
            string[] files = new string[10];
            // Load recently used files list
            RegistryAccess ra = new RegistryAccess(Registry.CurrentUser, RegPaths.Halo2RecentFiles);
            for (int i = 0; i < files.Length; i++)
            {
                files[i] = ra.getValue(i.ToString());
                if (files[i] != null) count++;
                if (files[i] == fileName) found = i;
            }
            ra.CloseReg();

            if (found == -1) found = count;
            if (found < pos)
            {
                int z = found;
                found = pos;
                pos = z;
            }

            for (int i = found; i > pos; i--)
                setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, i.ToString(), files[i-1]);
            setValue(Registry.CurrentUser, RegistryAccess.RegPaths.Halo2RecentFiles, pos.ToString(), fileName);
        }