vbnet Loop through files within a directory

Dim Directory As New IO.DirectoryInfo(My.Settings.DataPath)
Dim allFiles As IO.FileInfo() = Directory.GetFiles("*.xml")
Dim singleFile As IO.FileInfo

For Each singleFile In allFiles
	Console.WriteLine(singleFile.FullName)

	If File.Exists(singleFile.FullName) Then
		singleFile.Delete()
		singleFile.MoveTo("/newpath/" & singleFile.Name)
	End If
Next
Loops through xml files within a directory. A method could then be called passing the filename to it.

Updated: Sunday 10th October 2010, 10:26am

There are 0 comments

Leave a comment of your own

Comments are currently closed.