Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am trying to copy some files to folder. I am using the following statement to check if the source fie exists

If My.Computer.FileSystem.FileExists(fileToCopy) Then


But I donot know how to check if file exists in the folder before copying.
Please advise.

Thanks and best regards,
Furqan
Posted
Comments
Sergey Alexandrovich Kryukov 2-Dec-11 2:06am    
...By asking Google, if it did not ban you yet. :-)
--SA

VB
If System.IO.File.Exists(Dir + filename) Then
 
Share this answer
 
Try
VB
Dim MyFile As New FileInfo("FileLocation")
If MyFile.Exists() Then
    MessageBox.Show("File found.")
Else
    MessageBox.Show("File not found.")
End If


Reference Link :-
MSDN-[File.Exists Method][^] which will responsible to determines whether the specified file exists.
 
Share this answer
 
It's Very Simple :
VB
If System.IO.File.Exists("Path of the Folder with File Name") Then
            MessageBox.Show("Exist")
Else
            MessageBox.Show("Not Exist")
End If

Or
VB
If My.Computer.FileSystem.FileExists("Path of the Folder with File Name") Then
            MessageBox.Show("Exist")
Else
            MessageBox.Show("Not Exist")
End If
 
Share this answer
 
v2
Comments
Scubapro 2-Dec-11 2:27am    
This is the second time you're copycatting. Please check the already given solution(s) before adding one.
Manoj K Bhoir 2-Dec-11 2:51am    
Scubapro this is not copycatting.If OP is not satisfy with your answer then try to imporove your answer.If you are not doing that and other one is doing then is it copycatting????
Scubapro 2-Dec-11 5:53am    
And where exactly did the OP say that my solution wasn't satisfactory? Many OP's just do not rate our solutions, regrettably.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900