Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lines As String = ""
Dim p As New Process()
p.StartInfo.FileName = "CMD.exe" 'lance CMD
p.StartInfo.Arguments = "/c xcopy /y ""C:\Program Files\FujiFilm\config\Dicom.dat"" ""D:\Sauvegarde Netpix""" 'commande du copy des fichiers
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.UseShellExecute = False
p.Start()
lines = p.StandardOutput.ReadLine
TextBox1.Text = lines
End Sub
lorsque je clique sur le bouton1 non seulement la commande xcopy ne fonctionne pas et en plus il y a rien qui s'affiche dans le textbox.
Ton code est incomplet car tu dois t'abonner à l'événement OutputDatareceived, puis indiquer à ton process que la lecture externe a débuté. De plus, il faut ajouter un délégué pour éviter les opération inter-threads non valides.
A tester avec un textbox multilignes :
Option Strict On
Public Class Form1
Private Delegate Sub DelegateThread(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim p As New Process()
p.StartInfo.FileName = "CMD.exe" 'lance CMD
p.StartInfo.Arguments = "/c xcopy /y ""C:\Program Files\FujiFilm\config\Dicom.dat"" ""D:\Sauvegarde Netpix""" 'commande du copy des fichiers
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
AddHandler p.OutputDataReceived, AddressOf DonneesRecues
p.Start()
p.BeginOutputReadLine()
End Sub
Private Sub DonneesRecues(ByVal sender As Object, ByVal Ligne As DataReceivedEventArgs)
If Not String.IsNullOrEmpty(Ligne.Data) Then
If Me.InvokeRequired Then
Me.Invoke(New delegatethread(AddressOf DonneesRecues), sender, Ligne)
Else
TextBox1.Text &= Ligne.Data.ToString & Environment.NewLine
End If
End If
End Sub
End Class