zackmark29
Active member
- Joined
- Apr 21, 2020
- Messages
- 28
- Programming Experience
- Beginner
Could someone help me fix this codes?
It's only getting 51% result when the process is done
It's only getting 51% result when the process is done
VB.NET:
Dim counter As Double = 1
Dim outputFolder As String = txtFileOutput.Text + "\" + txtFileName.Text + ".ts"
Dim encryptionKey As Byte() = File.ReadAllBytes(txtKeyFile.Text)
Dim inputFilestream As FileStream
Dim outputFilestream As FileStream
Try
outputFilestream = New FileStream(outputFolder, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, FileOptions.SequentialScan)
For Each obj2 As Object In ListView1.Items
Dim sourceitem2 As SourceItem = CType(obj2, SourceItem)
Dim encryptionIV As Byte() = New Byte(15) {}
inputFilestream = New FileStream(sourceitem2.FileName, FileMode.Open, FileAccess.Read, FileShare.Read, FileOptions.SequentialScan)
Dim aes As New AesManaged With {
.Key = encryptionKey,
.IV = encryptionIV,
.Mode = CipherMode.CBC
}
Dim encryptor = aes.CreateDecryptor()
Dim cryptoStream = New CryptoStream(inputFilestream, encryptor, CryptoStreamMode.Read)
Dim count = sourceitem2.FileName.Length
'PROGRESSBAR
Dim value As Double = (counter / sourceitem2.FileName.Length) * 100
BackgroundWorker1.ReportProgress(CInt(value))
cryptoStream.CopyTo(outputFilestream)
counter += 1
inputFilestream.Close()
Next
outputFilestream.Flush()
outputFilestream.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try