private bool MinerProfileLoad()
        {
            DateTime start = DateTime.Now;
            try {
                Debug.Assert(MinerDllValid());
                if (!Directory.Exists(Settings.MinerDataFolder))
                    return false;

                VersionDataServer currentVersion = new VersionDataServer();
                string loadedMailVersion = "";
                VersionDataServer loadedVersion = SettingsServer.GetVersionData(Settings.ProfileFolder);
                if (loadedVersion != null)
                    loadedMailVersion = loadedVersion.MailDataVersion;

                //System.Diagnostics.Debugger.Break();
                int storeFileCount = Directory.EnumerateFiles(Settings.MinerDataFolder, "*.Store").Count();
                bool indexGixExists = File.Exists(Path.Combine(Settings.MinerDataFolder, "Index.Gix"));
                string unicodeDefFile = GetUnicodeDefFileName();
                if (!File.Exists(unicodeDefFile)) {
                    LogInfo("Unable to find the UnicodeDef.Bin file. Please make sure it is in the folder with the KEUI application or some folder upstream.");
                    return false;
                }

                if (storeFileCount == 0) {
                    LogInfo("There were no miner stores found. Unable to load miner data.");
                    return false;
                }

                if (currentVersion.MailDataVersion != loadedMailVersion) {
                    LogInfo("Miner contains information from previous version and is unable to load it.");
                    return false;
                }

                if (indexGixExists == false) {
                    LogInfo("The miner index files don't exist. Loading of miner data failed.");
                    return false;
                }

                lock (_serviceLock) {
                    ProfileHandle = ItemMinerControl.ItemMiner.ProfileLoad(Settings.MinerDataFolder + Path.DirectorySeparatorChar, unicodeDefFile, (int)EMinerFAccess.faUpdate, ProfileSettings.MinerIndexCacheSizeMB, ProfileSettings.MinerItemCacheSizeMB);
                }
                GenLib.Log.LogService.LogInfo(String.Format("Loading miner data needed {0:f0} miliseconds", (DateTime.Now - start).TotalMilliseconds));
                LogInfo("Loaded profile " + Settings.ProfileFolderName + ". Profile is in folder " + Settings.ProfileFolder);
            }
            catch (Exception ex) {
                LogInfo("MinerData.MinerProfileLoad exception: " + ex.Message);
                GenLib.Log.LogService.LogException("MinerData.MinerProfileLoad exception: ", ex);
            }
            return ProfileHandle != -1;
        }
 public static void WriteVersionData(string profileDir)
 {
     VersionDataServer versionData = new VersionDataServer();
     string path = Path.Combine(profileDir, "version.xml");
     try
     {
         using (FileStream fs = new FileStream(path, FileMode.Create))
         {
             new XmlSerializer(typeof(VersionDataServer)).Serialize(fs, versionData);
         }
     }
     catch (System.Exception ex) { GenLib.Log.LogService.LogException("Saving version data failed.", ex); }
 }