• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Simple question....moving files that start with a certain name

I have a directory that contains about 100 files.  Every day new files are going to be moved there for me and I would like to have a program that moves them into a folder.  The files will all start with "Finance".  They will be placed in the directory "L:\" and I would like to move them to  "L:\Finance".


1 Solution
Bob LearnedCommented:
Try something like this:

Imports System.IO

Public Class FileMover

  Public Shared Sub MoveFiles(ByVal sourceFolder As String, ByVal targetFolder As String, ByVal pattern As String)

    Dim directory As New DirectoryInfo(sourceFolder)

    For Each file As FileInfo In directory.GetFiles(pattern)
      Dim destFileName As String = Path.Combine(targetFolder, Path.GetFileName(file.FullName))
    Next file

  End Sub

End Class

   FileMover.MoveFiles("L:\", "L:\Finance", "Finance*.*")

collagesAuthor Commented:
Thats perfect, thanks a ton!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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