using System.Windows.Forms;
public partial class MainForm : Form
DragEnter += new DragEventHandler(Form1_DragEnter);
DragDrop += new DragEventHandler(Form1_DragDrop);
private void Form1_DragEnter(object sender, DragEventArgs e)
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
e.Effect = DragDropEffects.None;
private void Form1_DragDrop(object sender, DragEventArgs e)
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
string filePath = files[0];
if (File.Exists(filePath))
byte[] fileBytes = File.ReadAllBytes(filePath);
byte[] newFileBytes = new byte[fileBytes.Length + 1];
Array.Copy(fileBytes, newFileBytes, fileBytes.Length);
newFileBytes[fileBytes.Length] = 0x00;
string newFilePath = Path.GetFileNameWithoutExtension(filePath) + "_modified" + Path.GetExtension(filePath);
newFilePath = Path.Combine(Path.GetDirectoryName(filePath), newFilePath);
File.WriteAllBytes(newFilePath, newFileBytes);
MessageBox.Show($"Файл успішно змінено! Новий файл збережено за адресою: {newFilePath}", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show($"Помилка: {ex.Message}", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Файл не знайдено!", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);