//删除资源 public static void CardDelete(long id, YgoPath ygopath) { string[] files = ygopath.GetCardfiles(id); for (int i = 0; i < files.Length; i++) { if (FileSystem.FileExists(files[i])) FileSystem.DeleteFile(files[i], UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } }
//资源改名 public static void CardRename(long newid, long oldid, YgoPath ygopath) { string[] newfiles = ygopath.GetCardfiles(newid); string[] oldfiles = ygopath.GetCardfiles(oldid); for (int i = 0; i < oldfiles.Length; i++) { if (File.Exists(oldfiles[i])) { try { File.Move(oldfiles[i], newfiles[i]); } catch { } } } }
void Initialize(string datapath) { cardedit = new CardEdit(this); tmpCodes = new List<string>(); ygopath = new YgoPath(Application.StartupPath); InitPath(datapath); InitializeComponent(); title = this.Text; nowCdbFile = ""; }
void Initialize(string datapath) { cardedit = new CardEdit(this); tmpCodes = new List<string>(); ygopath = new YgoPath(Application.StartupPath); InitPath(datapath); InitializeComponent(); title = this.Text; nowCdbFile = ""; cmdManager.UndoStateChanged += delegate (bool val) { if (val) btn_undo.Enabled = true; else btn_undo.Enabled = false; }; }
public void ExportData(string path, string zipname) { int i = 0; Card[] cards = cardlist; if (cards == null || cards.Length == 0) return; int count = cards.Length; YgoPath ygopath = new YgoPath(path); string name = Path.GetFileNameWithoutExtension(zipname); //数据库 string cdbfile = zipname + ".cdb"; //说明 string readme = MyPath.Combine(path, name + ".txt"); //新卡ydk string deckydk = ygopath.GetYdk(name); File.Delete(cdbfile); DataBase.Create(cdbfile); DataBase.CopyDB(cdbfile, false, cardlist); if (File.Exists(zipname)) File.Delete(zipname); using (ZipStorer zips = ZipStorer.Create(zipname, "")) { zips.AddFile(cdbfile, name + ".cdb", ""); if (File.Exists(readme)) zips.AddFile(readme, "readme_" + name + ".txt", ""); if (File.Exists(deckydk)) zips.AddFile(deckydk, "deck/" + name + ".ydk", ""); foreach (Card c in cards) { i++; worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count)); string[] files = ygopath.GetCardfiles(c.id); foreach (string file in files) { if (File.Exists(file)) { zips.AddFile(file, file.Replace(path,""),""); } } } } File.Delete(cdbfile); }