-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmBinmerger.cs
100 lines (89 loc) · 3.44 KB
/
frmBinmerger.cs
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
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DevExpress.XtraEditors;
namespace VAGSuite
{
public partial class frmBinmerger : DevExpress.XtraEditors.XtraForm
{
public frmBinmerger()
{
InitializeComponent();
}
private void simpleButton2_Click(object sender, EventArgs e)
{
this.Close();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
try
{
if (File.Exists(buttonEdit1.Text))
{
if (File.Exists(buttonEdit2.Text))
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
// 3 bestanden bekend.. converteren
FileInfo fi = new FileInfo(buttonEdit1.Text);
FileInfo fi2 = new FileInfo(buttonEdit2.Text);
if (fi.Length == fi2.Length)
{
FileStream fs = File.Create(saveFileDialog1.FileName);
BinaryWriter bw = new BinaryWriter(fs);
FileStream fsi1 = File.OpenRead(buttonEdit1.Text);
BinaryReader br1 = new BinaryReader(fsi1);
FileStream fsi2 = File.OpenRead(buttonEdit2.Text);
BinaryReader br2 = new BinaryReader(fsi2);
for (int tel = 0; tel < fi.Length; tel++)
{
Byte ib1 = br1.ReadByte();
Byte ib2 = br2.ReadByte();
bw.Write(ib2);
bw.Write(ib1);
}
bw.Close();
fs.Close();
fsi1.Close();
br1.Close();
fsi2.Close();
br2.Close();
MessageBox.Show("Files merged successfully");
}
else
{
MessageBox.Show("File lengths don't match, unable to merge!");
}
}
}
}
}
catch (Exception E)
{
MessageBox.Show(E.Message);
}
this.Close();
}
private void buttonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
buttonEdit1.Text = openFileDialog1.FileName;
}
}
private void buttonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
buttonEdit2.Text = openFileDialog1.FileName;
}
}
}
}