Filesystemwatcher : récuperer le chemin d'un nouveau fichier crée
Bonjour,
Cela fait un moment que je cherche comment récupérer le chemin un fichier créer, je suis avertis pars une msgbox lorsqu'un dossier est créer.
Seulement j'aimerais que lorsque l'on clique sur "oui", le fichier s'affiche dans ma richtextbox qui est dans une autre form que mon filesystemwatcher.
Voici mon code :
Code:
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
| Option Strict On
Public Class Form3
Dim FSW As New IO.FileSystemWatcher
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FSW.Path = "\\PROPRIETAIRE-PC\Users\Proprietaire\Messagerie interne\Florence\Reçus"
AddHandler FSW.Created, AddressOf FichierCree
FSW.EnableRaisingEvents = False
FSW.EnableRaisingEvents = True
End Sub
Private Sub FichierCree(ByVal sender As Object, ByVal e As IO.FileSystemEventArgs)
'recuperation des donnees du fichier avec FileInfo
Dim monfichier As New IO.FileInfo(e.FullPath)
Dim msg As String
Dim titre As String
Dim style As MsgBoxStyle
Dim reponse As MsgBoxResult
msg = "Nouveau message !" & vbCrLf & "Voulez-vous l'ouvrir ?"
style = MsgBoxStyle.Information Or MsgBoxStyle.YesNo Or MsgBoxStyle.MsgBoxSetForeground Or MsgBoxStyle.SystemModal
titre = "Messagerie Interne"
reponse = MsgBox(msg, style, titre)
If reponse = MsgBoxResult.Yes Then
'Le fichier txt s'ouvre dans ma boite_de_reception.richtextbox1'
Else
End If
End Sub
End Class |
En vous remerciant par avance de vos réponses