-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm2.cs.txt
94 lines (84 loc) · 2.82 KB
/
Form2.cs.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
namespace Nintenlord.UPSpatcher
{
public partial class PatchCreator
{
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Title = "Select the original file.";
open.Filter = "All files|*";
open.Multiselect = false;
open.ShowDialog();
if (open.FileNames.Length > 0)
{
textBox1.Text = open.FileName;
}
}
private void button4_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Title = "Select the modified file.";
open.Filter = "All files|*";
open.Multiselect = false;
open.ShowDialog();
if (open.FileNames.Length > 0)
{
textBox2.Text = open.FileName;
}
}
private void button5_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Filter = "UPS file|*.ups";
save.Title = "Select where to save patch";
save.AddExtension = true;
save.OverwritePrompt = true;
save.ShowDialog();
if (save.FileNames.Length > 0)
{
textBox3.Text = save.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
byte[] original = null, modified = null;
try
{
BinaryReader br = new BinaryReader(File.OpenRead(textBox1.Text));
original = br.ReadBytes((int)br.BaseStream.Length);
br.Close();
}
catch (Exception)
{
MessageBox.Show("Error opening file\n" + textBox1.Text);
return;
}
try
{
BinaryReader br = new BinaryReader(File.Open(textBox2.Text, FileMode.Open));
modified = br.ReadBytes((int)br.BaseStream.Length);
br.Close();
}
catch (Exception)
{
MessageBox.Show("Error opening file\n" + textBox2.Text);
return;
}
UPSfile upsFile = new UPSfile(original, modified);
upsFile.writeToFile(textBox3.Text);
MessageBox.Show("Patch has been created.");
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}