Skip to content

Instantly share code, notes, and snippets.

@puppis42
Created May 26, 2023 17:34
Show Gist options
  • Save puppis42/b9e75b185367ac4974408abdc4a7b450 to your computer and use it in GitHub Desktop.
Save puppis42/b9e75b185367ac4974408abdc4a7b450 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Zip_File_Edit_Text
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
string code = "";
private void button1_Click(object sender, EventArgs e)
{
File.Copy(Application.ExecutablePath, @"C:\Users\uname\Desktop\tkk.txt");
try
{ // Open the text file using a stream reader.
using (StreamReader sr = new StreamReader(@"C:\Users\uname\Desktop\tkk.txt"))
{
// Read the stream to a string, and write the string to the console.
String line = sr.ReadToEnd();
code = line;
}
}
catch
{
}
using (FileStream zipToOpen = new FileStream(@"C:\Users\uname\Desktop\gg.zip", FileMode.Open))
{
using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
{
ZipArchiveEntry readmeEntry = archive.CreateEntry("a.exe");
using (StreamWriter writer = new StreamWriter(readmeEntry.Open()))
{
writer.WriteLine(code);
}
}
}
File.Delete(@"C:\Users\uname\Desktop\tkk.txt");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment