• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

VB.NET - check if file in a folder doesnt exists then copy and past from one folder to another..

I need to check and see if a folder
1 Solution
Reza RadConsultant, TrainerCommented:
IF (System.IO.File.Exists("c:\testFolder\test.txt")=False) then
Shahid ThaikaSole ProprietorCommented:
You can do something like the below...
Dim strLookForFile AS String
Dim strCopySourcePath AS String
Dim strCopyDestPath AS String

IF System.IO.File.Exists(strLookForFile) = False THEN
    System.IO.File.Copy(strCopySourcePath, strCopyDestPath, True)

Open in new window

Shahan AyyubSenior Software Engineer - iOSCommented:
Try this as well:

  • Use IO.File.Exists to check existance of file.
  • Use method FileCopy to Copy file
  • Inform the user for already existance(if occurs).

If IO.File.Exists("File Path") Then
            FileCopy("SourcePath", "DestinationPath")
            MsgBox("File Already Exists")
        End If

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now