Hi Experts! I'm new to VB.NET and need some help.
I need a windows service that will look at the file names in a shared folder, create sub folders based on those file names and then move the files into the appropriate folder. Ex.: File name 200601.jpg needs to go into the folder called 200601, File name 200602.jpg needs to go into the directory called 200602.
Here is what I have so far. It looks at the files, creates the subdirectories and moves the files, but I need help with moving the files into the correct folder.
Dim SourcePath As String = "Y:\SigFiles\"
Dim DestPath As String = "C:\SigFiles\"
Dim FileName As String
Dim Directory As New System.IO.DirectoryInfo(SourcePath)
Dim file As System.IO.FileInfo
For Each file In Directory.GetFiles
'check file name
FileName = Right(file.Name, 16)
FileName = Left(FileName, 6)
Dim DirInfo As New System.IO.DirectoryInfo(DestPath + FileName)
'check if the subdirectory already exists, if not, create it
If Not DirInfo.Exists Then System.IO.Directory.CreateDirectory(DestPath + FileName)
'move files to subdirectory based on name
file.MoveTo(DestPath + file.Name)