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
274 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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