mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-22 12:03:10 +00:00
Saving code
Dunno why this didn't sync...
This commit is contained in:
parent
35e4899e69
commit
30d13e796f
1 changed files with 12 additions and 2 deletions
|
@ -208,7 +208,7 @@ namespace PKHeX
|
|||
// Gotta read in the textbox.
|
||||
if (RTB_Code.Text.Length < 1) return;
|
||||
|
||||
byte[] ncf = new Byte[4 + RTB_Code.Lines.Count() * (3 * 4)];
|
||||
byte[] ncf = new Byte[4 + (RTB_Code.Lines.Count()-1) * (3 * 4)];
|
||||
Array.Copy(BitConverter.GetBytes(ncf.Length - 4), ncf, 4);
|
||||
|
||||
for (int i = 0; i < RTB_Code.Lines.Count()-1; i++)
|
||||
|
@ -221,11 +221,21 @@ namespace PKHeX
|
|||
Array.Copy(BitConverter.GetBytes(UInt32.Parse(rip[1], NumberStyles.HexNumber)),0,ncf,4+i*12+4,4);
|
||||
Array.Copy(BitConverter.GetBytes(UInt32.Parse(rip[2], NumberStyles.HexNumber)),0,ncf,4+i*12+8,4);
|
||||
}
|
||||
int z = 0;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.FileName = "code.bin";
|
||||
sfd.Filter = "Code File|*.bin";
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string path = sfd.FileName;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// File already exists, save a .bak
|
||||
byte[] backupfile = File.ReadAllBytes(path);
|
||||
File.WriteAllBytes(path + ".bak", backupfile);
|
||||
}
|
||||
File.WriteAllBytes(path, ncf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue