Bonjour,

Je souhaiterais via une application .net connaître le taux de fragmentation du disque dur.
La commande defrag c: -a permet d'analyser le disque c: via l'invite de commandes mais je n'arrive pas à récupérer le texte en sortie.

Voici mon code (VB.NET)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
Dim p As Process = Nothing
Try
     p = Process.Start(New ProcessStartInfo("C:\WINDOWS\system32\defrag.exe", "c: -a"))
     If p.WaitForExit(60 * 1000) Then
          MessageBox.Show(p.StandardOutput.ReadToEnd(), "StandardOutput")
          p.Dispose()
          p = Nothing
     End If
Catch ex As Exception
     MessageBox.Show(ex.Message, "Exception")
Finally
     If p IsNot Nothing Then
          If Not p.HasExited Then
              p.Kill()
          End If
          p.Dispose()
          p = Nothing
     End If
End Try
Ce code retourne l'exception suivante :
StandardOut n'a pas été redirigé ou le processus n'a pas encore commencé.

Comment faire pour récupérer le texte généré par la commande defrag ?

Ou alors existe-t-il un objet .net permettant d'analyser le hdd ?

Merci d'avance