Website Design United States, Website Design California, Website Designing United States, Website Designing California

File Copy Using File.Copy Method in VB.Net - Visual Basic .NET

a file using the File.Copy Method from the .Net framework.

Imports System
Imports System.IO

Module Module1

Sub Main()

Dim sourceFile As String = "C:\SourceFile.txt"
Dim destinationFile As String = "C:\DestinationFile.txt"

Try 'Attempt file copy

'Delete destinationFile for overwrite,
'causes exception if already exists.
File.Delete(destinationFile)

File.Copy(sourceFile, destinationFile)

'Successful if the method gets this far without causing an exception
Console.WriteLine("Copy completed.")

Catch exc As Exception 'If the file copy fails then catch will gain control of the method
'Oops something didn't work
Console.WriteLine(exc.Message)
End Try

Console.Write(vbCrLf & "Press Enter to Continue:")
Console.Read()
End Sub

End Module


WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com