public void openFile(string path) { string ext = Path.GetExtension(path); FileInfo fi = new FileInfo(path); if (fi.Length > 0x802C) { Util.Error("Input file is too large.", path); } else { byte[] input; try { input = File.ReadAllBytes(path); } catch { Util.Error("File is in use by another program!", path); return; } try { openFile(input, path, ext); } catch { try { PokemonList empty = new PokemonList((byte[])PokemonList.EMPTY_LIST.Clone()) { [0] = { OT_Name = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "Rhydon", JP_Mode) }, [0] = { Nickname = RBY_Encoding.GetBytes(JP_Mode ? "サイドン" : "RHYDON", JP_Mode) }, [0] = { TID = 12345 }, [0] = { Species = 1 }, [0] = { Level = 1 } }; openFile(empty.GetBytes(), path, ext); } catch { openFile(input, path, ext); } } } }
private void PB_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left || e.Clicks != 1 || inChildForm) { return; } byte[] dragdata = pk1_wrapper.GetBytes(); string filename = RBY_Encoding.GetString(pk1.Nickname, JP_Mode) + " - " + RBY_Encoding.GetString(pk1.OT_Name, JP_Mode) + (JP_Mode ? ".jpk1" : ".pk1"); string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename)); try { File.WriteAllBytes(newfile, dragdata); DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); } catch (ArgumentException x) { Util.Error("Drag & Drop Error:", x.ToString()); } File.Delete(newfile); }