Showing posts with label VB .Net.. Show all posts
Showing posts with label VB .Net.. Show all posts

Thursday, December 19, 2013

Copy and Delete Files using VB .Net



Copy and Delete Files using VB .Net




Environment:


Visual Studio 2005
Visual Basic


Header:


Imports System
Imports System.IO


Copy


Function:
File.Copy(SourceFile, DestinationFile)

Example :     
File.Copy("C:\test.txt", "C:\test.txt")


Delete


Function:
File.Delete(DestinationFile)

Example :  
File.Delete("C:\test.txt")


Copy and Delete Files using VB .Net Example Coding


Dim FileToCopy As String
Dim NewCopy As String

FileToCopy = "C:\test.txt"
NewCopy = "C:\NewTest.txt"

If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
MsgBox("File Copied")
End If