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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now