How to check if file already exists in the folder

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


Dim SourcePath as string = "c:\SomeFolder\SomeFileYouWantToCopy.txt" 'This is just an example string and could be anything, it maps to fileToCopy in your code.
Dim SaveDirectory as string = "c:\DestinationFolder"

Dim Filename as string = 'get the filename of the original file without the directory on it
Dim SavePath as string =, Filename) 'combines the saveDirectory and the filename to get a fully qualified path.

if then
   'The file exists
    'the file doesn't exist
end if

Need Your Help

memory management in nested blocks

objective-c memory-management objective-c-blocks

References to local variables (including ivars) inside blocks are automatically retained to make sure it remains valid throughout the execution of the block.

NullPointerException When Making an Animation

android animation nullpointerexception android-viewpager android-context

I have one really annoying problem in my android app and I just cant figure out what the problem is.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.