Exemple #1
0
        public static void CardDelete(long id, YgoPath ygopath, DeleteOption option)
        {
            string[] files    = ygopath.GetCardfiles(id);
            string[] bakfiles = ygopath.GetCardfiles(id, true);
            switch (option)
            {
            case DeleteOption.BACKUP:
                for (int i = 0; i < files.Length; i++)
                {
                    if (File.Exists(bakfiles[i]))
                    {
                        File.Delete(bakfiles[i]);
                    }
                    if (File.Exists(files[i]))
                    {
                        File.Move(files[i], files[i] + ".bak");
                    }
                }
                break;

            case DeleteOption.RESTORE:
                for (int i = 0; i < bakfiles.Length; i++)
                {
                    if (File.Exists(files[i]))
                    {
                        File.Delete(files[i]);
                    }
                    if (File.Exists(bakfiles[i]))
                    {
                        File.Move(bakfiles[i], bakfiles[i].Replace("bak", ""));
                    }
                }
                break;

            case DeleteOption.CLEAN:
                for (int i = 0; i < bakfiles.Length; i++)
                {
                    if (File.Exists(bakfiles[i]))
                    {
                        File.Delete(bakfiles[i]);
                    }
                }
                break;

            case DeleteOption.NONE:
                for (int i = 0; i < files.Length; i++)
                {
                    if (File.Exists(files[i]))
                    {
                        File.Delete(files[i]);
                    }
                }
                break;
            }
        }
Exemple #2
0
 //删除资源
 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);
         }
     }
 }
Exemple #3
0
        public void ExportData(string path, string zipname, string _cdbfile)
        {
            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, Path.GetFileNameWithoutExtension(_cdbfile) + ".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);
        }
Exemple #4
0
        public static void CardCopy(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.Copy(oldfiles[i], newfiles[i], false);
                    }
                    catch { }
                }
            }
        }
Exemple #5
0
        //资源改名
        public static void CardRename(long newid, long oldid, YgoPath ygopath, bool delold)
        {
            string[] newfiles = ygopath.GetCardfiles(newid);
            string[] oldfiles = ygopath.GetCardfiles(oldid);

            for (int i = 0; i < oldfiles.Length; i++)
            {
                if (File.Exists(oldfiles[i]))
                {
                    if (delold)
                    {
                        File.Move(oldfiles[i], newfiles[i]);
                    }
                    else
                    {
                        File.Copy(oldfiles[i], newfiles[i], false);
                    }
                }
            }
        }