Lo que quiero es correr un ProgressBar en segundo plano o un Label mostrando el "porcentaje" mientras termina de comprimir los archivos para evitar que parezca como si se hubiese freezeado o paralizado la aplicacion, anexo el codigo!
Código vb:
Ver original
Imports System.IO Imports System.IO.DirectoryInfo Imports System.IO.Directory Imports Ionic.Zip Imports System Public Class Form1 Private strPath As String Dim txt As String, bol As Boolean Dim a As String = ".zip" Private Sub btnArchivo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArchivo.Click Try With FolderBrowserDialog1 .Reset() .Description = " Seleccionar una carpeta " .SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) .ShowNewFolderButton = False Dim ret As DialogResult = .ShowDialog If ret = Windows.Forms.DialogResult.OK Then 'Dim nFiles As ObjectModel.ReadOnlyCollection(Of String) 'nFiles = My.Computer.FileSystem.GetFiles(.SelectedPath, FileIO.SearchOption.SearchAllSubDirectories) TextBox1.Text = FolderBrowserDialog1.SelectedPath.ToString() End If .Dispose() End With Catch oe As Exception MsgBox(oe.Message, MsgBoxStyle.Critical) End Try End Sub Public Sub Comprimirtxt() Dim txtFiles = Directory.GetFiles(Me.TextBox1.Text, "*.txt", SearchOption.AllDirectories) For Each currentFile As String In txtFiles Using zip As ZipFile = New ZipFile() zip.AddFile(currentFile, "") zip.Save(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(currentFile), System.IO.Path.GetFileNameWithoutExtension(currentFile) + ".zip")) File.Delete(currentFile) End Using Next End Sub Private Sub btnComprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComprimir.Click BackgroundWorker1.RunWorkerAsync() If TextBox1.Text = "" Then MessageBox.Show("Seleccione una carpeta a comprimir") Else Comprimirtxt() MessageBox.Show("Accion Finalizada!", "Accion exitosa", MessageBoxButtons.OK) End Class
Ese es mi codigo y ya llevo atorado como 5 dias URGE :/ Saludos!