protected void LoadList() { string strFileName = System.IO.Path.Combine(MuleApplication.Instance.Preference.GetMuleDirectory(Mule.Preference.DefaultDirectoryEnum.EMULE_CONFIGDIR), CLIENTS_MET_FILENAME); if (!System.IO.File.Exists(strFileName)) { return; } SafeBufferedFile file = null; try { file = MpdObjectManager.CreateSafeBufferedFile(strFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None); byte version = file.ReadUInt8(); if (version != (byte)VersionsEnum.CREDITFILE_VERSION && version != (byte)VersionsEnum.CREDITFILE_VERSION_29) { file.Close(); return; } // everything is ok, lets see if the backup exist... string strBakFileName = System.IO.Path.Combine(MuleApplication.Instance.Preference.GetMuleDirectory(Mule.Preference.DefaultDirectoryEnum.EMULE_CONFIGDIR), string.Format("{0}{1}", CLIENTS_MET_FILENAME, ".bak")); uint dwBakFileSize = 0; bool bCreateBackup = true; if (System.IO.File.Exists(strBakFileName)) { FileInfo fInfo = new FileInfo(strBakFileName); dwBakFileSize = (uint)fInfo.Length; if (dwBakFileSize > (uint)file.Length) { // the size of the backup was larger then the org. file, something is wrong here, don't overwrite old backup.. bCreateBackup = false; } } //else: the backup doesn't exist, create it if (bCreateBackup) { file.Close(); // close the file before copying System.IO.File.Copy(strFileName, strBakFileName, true); file = MpdObjectManager.CreateSafeBufferedFile(strFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None); file.Seek(1, SeekOrigin.Begin); //set filepointer behind file version byte } uint count = file.ReadUInt32(); uint dwExpired = MpdUtilities.Time() - 12960000; // today - 150 day uint cDeleted = 0; for (uint i = 0; i < count; i++) { CreditStruct newcstruct = new CreditStruct(); if (version == (byte)VersionsEnum.CREDITFILE_VERSION_29) { ReadCreditStruct29a(file, newcstruct); } else { ReadCreditStruct(file, newcstruct); } if (newcstruct.nLastSeen < dwExpired) { cDeleted++; continue; } ClientCredits newcredits = MuleApplication.Instance.CoreObjectManager.CreateClientCredits(newcstruct); clients_[new MapCKey(newcredits.Key)] = newcredits; } file.Close(); } catch (Exception error) { MpdUtilities.DebugLogError(error); file.Close(); } }