Tuesday, November 29, 2011

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")


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


 
Post a Comment