Torna al Thread
Imports System.IO
Public Class Form1
Private Sub btn_add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_add.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim S() As String = OpenFileDialog1.FileNames 'un array che contiene i nomi dei file scelti
Dim File As String
For Each File In S
ListBox1.Items.Add(File)
Next
End If
End Sub
Private Sub btn_create_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_create.Click
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim W As New IO.StreamWriter(SaveFileDialog1.FileName)
Dim R As IO.StreamReader
Dim File As String
'il valore massimo della proprietà value della progressbar
ProgressBar1.Maximum = ListBox1.Items.Count
'il valore iniziali della progressbar
ProgressBar1.Value = 0
LabelStatus.Text = "Creazione File in corso..."
' scrittura del file
For i As Int16 = 0 To ListBox1.Items.Count - 1
File = ListBox1.Items(i)
R = New IO.StreamReader(File)
W.WriteLine(R.ReadToEnd)
R.Close()
R = Nothing
ProgressBar1.Value += 1
Next
LabelStatus.Text = "File creato"
ProgressBar1.Value = 0
End If
End Sub
End Class