SiteMap  | About    

How to Copy , Delete File

The File Class is using the operations such as copying, moving, renaming, creating, opening, deleting, and appending to files.

IOException is the base class for exceptions thrown while accessing information using streams, files and directories. FileNotFoundException Class is thrown the exception when an attempt to access a file that does not exist on disk fails.

The following program shows how to use File Class for copying and deleting a text file and also its shows how to handle System.IO.FileNotFoundException Class.

Imports System.IO
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
			File.Copy("c:\\temp.txt", "c:\\copytemp.txt", True)
		Catch ex As System.IO.FileNotFoundException
		End Try
	End Sub

End Class (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.