I need to copy files from "F:\" to "E:\" but I don't want to copy all the files just the ones that have been changed or updated since I logged on to the computer.
Does anyone have a way to do this please?
Thanks in advance.
------
KNXRB
Printable View
I need to copy files from "F:\" to "E:\" but I don't want to copy all the files just the ones that have been changed or updated since I logged on to the computer.
Does anyone have a way to do this please?
Thanks in advance.
------
KNXRB
Drop a FileSystemWatcher to your form and try this.
Public Class Form1
Private changedFiles As New List(Of String)
VB.Net Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load FileSystemWatcher1.Path = "F:\" 'I assume that you want to include the subdirectories. If not, remove the line underneath. FileSystemWatcher1.IncludeSubdirectories = True End Sub Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed If e.ChangeType = IO.WatcherChangeTypes.Changed Then Dim filePath As String = e.FullPath If IO.File.Exists(filePath) AndAlso Not changedFiles.Contains(filePath) Then 'This will filter out the directories and prevent duplicates from being added. changedFiles.Add(e.FullPath) End If End If End Sub End Class
It'll find all the files in F: that has had changes made to them. Now just copy the files to E:, all the filepaths are in the changedFiles list.