Cara meng-extract file rar menggunakan VB Net
Salah satu cara untuk meng-extract suatu file rar adalah dengan menggunakan software winrar itu sendiri. oleh karena itu, sebelumnya dalam komputer harus diinstall software winrar. setelah itu, baru kita membuat coding vb agar software winrar dapat dijalankan melalui program kita.
Private Sub UnRar(ByVal WorkingDirectory As String, ByVal filepath
As String)
' Microsoft.Win32 and System.Diagnostics namespaces are imported
Dim objRegKey As RegistryKey
objRegKey =
Registry.ClassesRoot.OpenSubKey("WinRAR\Shell\Open\Command")
' Windows 7 Registry entry for WinRAR Open Command
Dim obj As Object = objRegKey.GetValue("")
Dim objRarPath As String = obj.ToString()
objRarPath = objRarPath.Substring(1, objRarPath.Length - 7)
objRegKey.Close()
Dim objArguments As String
' in the following format
' " X G:\Downloads\samplefile.rar G:\Downloads\sampleextractfolder\"
objArguments = " X " & " " & filepath & " " + " " +
WorkingDirectory
Dim objStartInfo As New ProcessStartInfo()
' Set the UseShellExecute property of StartInfo object to FALSE
' Otherwise the we can get the following error message
' The Process object must have the UseShellExecute property set to
false in order to use environment variables.
objStartInfo.UseShellExecute = False
objStartInfo.FileName = objRarPath
objStartInfo.Arguments = objArguments
objStartInfo.WindowStyle = ProcessWindowStyle.Hidden
objStartInfo.WorkingDirectory = WorkingDirectory & "\"
Dim objProcess As New Process()
objProcess.StartInfo = objStartInfo
objProcess.Start()
End Sub
source information:
http://www.kodyaz.com/articles/how-to-unrar-rar-files-using-vb.net-extract-code.aspx