Imports System.IO
Public Class Form1
Private Chemin As New OpenFileDialog
Private Fichier As String ="D:\Document\Calcul.xlsm"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If File.Exists(Fichier) Then
MsgBox("Le fichier existe")
Else
MsgBox("Le fichier n'existe pas")
End If
End Class
Private Chemin As New OpenFileDialog
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Chemin.ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox1.Text = Chemin.FileName
End If
End Sub
Dim curFile As String = "D:\Document\Calcul.xlsm" MsgBox(If(File.Exists(curFile), "File exists.", "File does not exist."))
Dim curFile As String = "D:\Document\Calcul.xlsm" If File.Exists(curFile) Then MsgBox("Le fichier existe") Else MsgBox("Le fichier n'existe pas") End If
"C:\Users\LePivert\Documents\lienhypertexte.xls"
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim curFile As String = "D:\MDP.txt"
MsgBox(If(File.Exists(curFile), "Le fichier existe", "Le fichier n'existe pas"))
If File.Exists(curFile) Then
MsgBox("Le fichier existe")
Else
MsgBox("Le fichier n'existe pas")
End If
End Sub
End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question"D:\MDP.txta été rentrée manuellement au clavier et le fichier existe ( la preuve sur l'image jointe )
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim curFile As String = "D:\MDP.txt"
MsgBox(If(File.Exists(curFile), "File exists.", "File does not exist."))
End Sub
End Class
Public Class Form1
Dim curFile As String = "D:\Document\Calcul.xlsm"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IO.File.Exists(curFile) Then
MsgBox("Le fichier existe")
Else
MsgBox("Le fichier n'existe pas")
End If
End Sub
End Class
Public Class Form1
Dim curFile As String = "D:\Document\Calcul.xlsm"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(If(IO.File.Exists(curFile), "Le fichier existe", "Le fichier n'existe pas"))
End Sub
End Class
Modifié le 14 avril 2017 à 11:58