1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Private Function UnRar(ByVal FileName As String, ByVal ExtractDir As String) As Boolean
Dim Success As Boolean = False
Dim CodeDeSorti As Integer
Try
Dim proc As New Process()
With proc
With .StartInfo
.UseShellExecute = False
#If DEBUG Then
.FileName = "UnRar.exe"
#Else
.FileName = My.Application.Info.DirectoryPath & "\UnRaR.exe"
#End If
.Arguments = " x -ibck -inul -or -y " & " """ & FileName & """ """ & ExtractDir & """"
'x Extraire des fichiers d'une archive, en tenant compte de leurs chemins complets
'-inul Désactive les messages d'erreur
'-or Renommer les fichiers automatiquement
'-y Considère toutes les réponses aux questions comme "Oui"
'-p[mdp] Utilise un mot de passe
.WorkingDirectory = ExtractDir
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
.Start()
.WaitForExit()
CodeDeSorti = .ExitCode
.Close()
End With
If CodeDeSorti < 2 Then '0 Opération réussie. 1 Avertissement. Une erreur non fatale s'est produite.
Success = True
End If
Catch ex As Exception
End Try
Return Success
End Function |