Solved

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

Posted on 2010-08-14
3
276 Views
Last Modified: 2013-11-26
I need to check and see if a folder
0
Comment
Question by:GlobaLevel
3 Comments
 
LVL 30

Expert Comment

by:Reza Rad
ID: 33439518
IF (System.IO.File.Exists("c:\testFolder\test.txt")=False) then
 ....
0
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 33439521
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)
END IF

Open in new window

0
 
LVL 19

Accepted Solution

by:
Shahan Ayyub earned 500 total points
ID: 33440334
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")
        Else
            MsgBox("File Already Exists")
        End If

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question