9 Ekim 2016 Pazar

c# exe boyutunu artırma

Bu kodlamanın ne işe yaradığını bilmeyen arkadaşlar için açıklayacak olursak bu kodlama sizin uygulamalarınızın boyutunu arttırır.Mesela 1 megabaytlık bir exe dosyanız var bunun boyutunu bu kodlama sayesinde 3 veya daha fazla olmasını sağlayabilirsiniz.Şimdi soruyorsunuzdur “Peki exe dosyamızı bozacak mı? ” diye.Kesinlikle dosyanızda bozulma olmaz.
Bu kodlamayı çalıştırmak için gerekli elemanlar:
  • 2 adet button
  • 2 adet radiobutton
  • 2 adet textbox
  • 1 adet openFileDialog
Kod:
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
namespace AddBytes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
var file = File.OpenWrite(textBox1.Text);
var siza = file.Seek(0, SeekOrigin.End);
var size = Convert.ToInt32(textBox2.Text);
if (radioButton1.Checked)
{
decimal bite = size*1048576;
while (siza < bite)
{
siza++;
file.WriteByte(0);
}
file.Close();
}
else if (radioButton2.Checked)
{
decimal bite = size*1048;
while (siza < bite)
{
siza++;
file.WriteByte(0);
}
file.Close();
}
MessageBox.Show(“İşlem yapıldı!”);
}
private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.DefaultExt = “exe”;
openFileDialog1.Filter = “exe files (*.exe)|*.exe”;
openFileDialog1.FilterIndex = 1;
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
textBox1.Text = string.Empty;
textBox1.Text = openFileDialog1.FileName;
}
}
}
}