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

Answers


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 = system.io.path.getFileName(SourcePath) 'get the filename of the original file without the directory on it
Dim SavePath as string = system.io.path.combine(SaveDirectory, Filename) 'combines the saveDirectory and the filename to get a fully qualified path.

if system.io.file.exists(SavePath) then
   'The file exists
else
    'the file doesn't exist
end if

Need Your Help

Test Explorer not discovering Xunit tests

unit-testing resharper visual-studio-2015 xunit test-explorer

I am currently running VS 2015 Enterprise edition. My global.json file is as follows:

Having issues with making my first webproject with Maven and Eclipse

java eclipse spring maven

I am aving a issues with making my first webproject with Maven and Eclipse...