private void 检查更新版本数据库() { //TODO 检查数据库是否存在AMSkins数据库 if (_skin.CheckAmSkins()) { WriteTitle("开启数据整理!"); //TODO 如果存在则复制此表的数据到Skin表 var oldlist = _skin.AmSkinList(); var list = _lumei.AllSkins(); var i = 0; try { var path = ""; foreach (var item in oldlist) { i++; WriteMessage("数据整理中……[" + i + "/" + oldlist.Count + "]"); if (list.Any(d => d.SkinName == item.SkinName)) { continue; } //TODO 将文件移动到新的文件夹 var oldpath = Soft.SkinOldPath(item); if (!Directory.Exists(oldpath)) { continue; } path = Soft.SkinPath(item); if (Directory.Exists((path))) { Directory.Delete(path, true); } FileOperations.CreateDir(Soft.Skins); Directory.Move(oldpath, path); var load = Soft.SkinLoadPath(item); if (File.Exists(load) && !load.EndsWith(".png")) { try { using (var image = DevIL.DevIL.LoadBitmap(load)) { var rep = load.Substring(load.Length - 3, 3); var newimg = load.Replace(rep, "png"); DevIL.DevIL.SaveBitmap(newimg, image); item.LoadPic = item.LoadPic.Replace(rep, "png"); } File.Delete(load); } catch (Exception ex) { Log.LogError("载入图转换失败", ex); } } _skin.Add(item); } //TODO 并删除AMSkins表 path = string.Format("{0}Skins\\", AppDomain.CurrentDomain.BaseDirectory); if (Directory.Exists(path)) { Directory.Delete(path, true); } WriteMessage(_skin.DeleAmSkin() ? "数据整理完成!" : "数据整理失败!"); } catch (Exception ex) { Log.LogError("数据整理失败!", ex); AyMessageBox.Show("请确认程序拥有对软件目录的读写权限", "数据整理失败!"); } } }