Untitled
unknown
plain_text
a year ago
1.1 kB
4
Indexable
using System.IO.Compression; internal class Program { //ARCHIVATOR private static void Main(string[] args) { Random random = new Random(); Console.WriteLine("Введите путь к файлу/папке: "); string sourcePath = Console.ReadLine(); string zipRootPath = "C:\\Juan\\file.zip"; if (File.Exists(sourcePath) ) { using(ZipArchive archive = ZipFile.Open(zipRootPath + $"{random.Next(1000):d4}.zip", ZipArchiveMode.Create)) { archive.CreateEntryFromFile(sourcePath, Path.GetFileName(sourcePath)); Console.WriteLine("Архив успешно создан"); } } else if (Directory.Exists(sourcePath)) { ZipFile.CreateFromDirectory(sourcePath, zipRootPath + $"{random.Next(1000):d4}.zip"); Console.WriteLine("Архив с файлами папки был успешно создан"); } } }
Editor is loading...
Leave a Comment