[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Iterating Through & Renaming Files.

Just after how to do a couple of things.

1. Iterate through a directory file by file and get the filename.

2. Rename a file.

Thanks in Advance :)
Jaz
0
jazduck
Asked:
jazduck
1 Solution
 
Bob LearnedCommented:
Imports System.IO

Public Class FileOperations

  Public Sub RenameFilesInFolder(ByVal pathFolder As String, ByVal fileExtension As String)

    Dim dirInfo As DirectoryInfo = New DirectoryInfo(pathFolder)

    ' Loop through each of the files using the pattern *.jpg for example.
    For Each fileCurrent As FileInfo In dirInfo.GetFiles("*." & fileExtension)
      Rename(fileCurrent.Name, "Renamed-" & fileCurrent.Name)
    Next

  End Sub

End Class

Bob
0
 
jazduckAuthor Commented:
Thanks Bob :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now