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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

18 Experts available now in Live!

Get 1:1 Help Now