An advanced properties window made in VB.Net
Get the latest version here, and the latest build from commit here (note that these builds are built for the Debug config and so are not optimised)
If getting the latest build from commit, download PropertiesDotNet-Ookii.Dialogs.dll for full functionality.
- Program Icon:
- Compress form icon:
- Hashing form icon:
- Find at: PropertiesDotNet.vb#L6
- And: PropertiesDotNet.vb#L147
- http://www.vb-helper.com/howto_get_associated_program.html
- The page above is in VB6 however, so I needed to convert it (manually) to VB.Net. Also, the most important line, the
Function FindExecutable Lib "shell32.dll"
, is chopped off the sample you see on the page, so you have to download thezip
to get that.
- Find at: CompressReport.vb#L59
- And: CompressReport.vb#L68
- http://www.thescarms.com/dotnet/NTFSCompress.aspx
- Original code from above link has been copied, un-modified, to NTFSCompressOriginalCode.cs
- I have edited it so it can be compiled: NTFSCompressConvertable.cs
- Then I converted it to VB.Net: NTFSCompressConverted.vb
- MSDN Info (for decompression value): https://msdn.microsoft.com/en-us/library/windows/desktop/aa364592(v=vs.85).aspx
- Find at: Hashes.vb#L405
- Basic Hashing: http://us.informatiweb.net/programmation/36--generate-hashes-md5-sha-1-and-sha-256-of-a-file.html
- Hashing with progress reporting: http://www.infinitec.de/post/2007/06/09/Displaying-progress-updates-when-hashing-large-files.aspx
- Since the code on the page above is in C#, I converted it to VB.Net:
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Imports System.Security
Imports System.Security.Cryptography
Namespace NTFSCompress
Public Partial Class MainForm
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub BackgroundWorker_DoWork(sender As Object, e As DoWorkEventArgs)
Dim buffer As Byte()
Dim oldBuffer As Byte()
Dim bytesRead As Integer
Dim oldBytesRead As Integer
Dim size As Long
Dim totalBytesRead As Long = 0
Using stream As Stream = File.OpenRead(DirectCast(e.Argument, String))
Using hashAlgorithm As HashAlgorithm = MD5.Create()
size = stream.Length
buffer = New Byte(4095) {}
bytesRead = stream.Read(buffer, 0, buffer.Length)
totalBytesRead += bytesRead
Do
oldBytesRead = bytesRead
oldBuffer = buffer
buffer = New Byte(4095) {}
bytesRead = stream.Read(buffer, 0, buffer.Length)
totalBytesRead += bytesRead
If bytesRead = 0 Then
hashAlgorithm.TransformFinalBlock(oldBuffer, 0, oldBytesRead)
Else
hashAlgorithm.TransformBlock(oldBuffer, 0, oldBytesRead, oldBuffer, 0)
End If
BackgroundWorker.ReportProgress(CInt(Math.Truncate(CDbl(totalBytesRead) * 100 / size)))
Loop While bytesRead <> 0
e.Result = hashAlgorithm.Hash
End Using
End Using
End Sub
End Class
End Namespace