How to move files older than today's date to other folder


How to move files older than today’s date to other folder?
While moving other files in folder I want to keep the files which are modified today.
All other old files I want to move to Archive Folder

PLs help


Please check this


Try below approach:-

  1. Assign todayDate = DateTime.Now.Date
  2. Assign sourceFolderPath = “Path to source folder”
  3. Assign destinationFolderPath = “Path to destination folder”
  4. Assign files = Directory.GetFiles(sourceFolderPath)
  5. For Each file in files
  6. Assign fileCreationDate = File.GetCreationTime(file)
  7. If fileCreationDate < todayDate
  8.     Move File: From file To destinationFolderPath
  9. End If
  10. End For Each

This is how to get a list of the files you want…

New System.IO.DirectoryInfo("C:\temp").GetFiles("*").Where(Function(s) (CDate(s.CreatedDate) < Today))

Just put that into a For Each: