Как установить предельный размер zip-файла
В настоящее время я разрабатываю проект zip, который должен установить предельный размер во время процесса молнии и настроить автоматический запуск процесса плавно на основе предельного размера. Например, сначала мы должны проанализировать общий размер данных, а затем установить первый файл, который будет заархивирован как 200 ГБ для предельного пространства, тогда он все равно будет выполнять второй файл непрерывно на основе предельного размера. Может ли кто-нибудь поделиться идеей/решением.
Что я уже пробовал:
Below are my code. <pre>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; using System.Threading; using Ionic.Zip; namespace Zip_Test { public partial class Form1 : Form { private bool isFolder = false; public Form1() { InitializeComponent(); } private void btn_zip_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtbox_folder.Text)) { MessageBox.Show("PLEASE SELECT A FOLDER OR FILE TO BE ZIP"); return; } else { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = @"C:\"; sfd.Filter = "Zip Files|*.zip;*.rar"; sfd.FilterIndex = 0; sfd.RestoreDirectory = true; sfd.Title = "SAVE ZIP FILE TO"; sfd.FileName = "ZIP FILE " + DateTime.Now.ToString("dd-MMMM-yyyy hh.mm.ss tt"); if (sfd.ShowDialog() == DialogResult.OK) { if (isFolder == true) { //ZipFile.CreateFromDirectory(txt_folderPath.Text, sfd.FileName); string path = txtbox_folder.Text; Thread thread = new Thread(t => { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) { zip.AddDirectory(path); System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path); //zip.SaveProgress += Zip_SaveProgress; zip.Save(string.Format("{0}\\{1}.zip", di.Parent.FullName, di.Name)); } }) { IsBackground = true }; thread.Start(); } else { string fileName = txtbox_folder.Text; Thread thread = new Thread(t => { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) { FileInfo fi = new FileInfo(fileName); zip.AddFile(fileName); System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(fileName); //zip.SaveProgress += Zip_SaveFileProgress; zip.Save(string.Format("{0}/{1}.zip", di.Parent.FullName, di.Name)); } }) { IsBackground = true }; thread.Start(); // string[] files = txt_folderPath.Text.Split(','); //ZipArchive zip = ZipFile.Open(sfd.FileName, ZipArchiveMode.Create); // foreach (string file in files) //{ //zip.CreateEntryFromFile(file, Path.GetFileName(file), CompressionLevel.Optimal); //} } MessageBox.Show("ZIP file created successfully!"); } else { return; } } } private void btn_folder_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.OK) { btn_reset.Enabled = true; txtbox_folder.Text = fbd.SelectedPath; isFolder = true; if (Directory.GetFiles(txtbox_folder.Text).Length > 0) { foreach (string file in Directory.GetFiles(txtbox_folder.Text)) { //Add file in ListBox. listBox1.Items.Add(file); } } //string[] filePaths = Directory.GetFiles(txt_folderPath.Text, "*.*", SearchOption.TopDirectoryOnly); //for (int i = 0; i < filePaths.Length; i++) //{ // listBox1.Items.Add(filePaths[i]); //} } else { return; } } private void btn_reset_Click(object sender, EventArgs e) { txtbox_folder.Text = null; listBox1.Items.Clear(); btn_reset.Enabled = false; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { } } }