Results 1 to 2 of 2

Thread: [2005] Copy Files Help Needed!

  1. #1

    Thread Starter
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    [2005] Copy Files Help Needed!

    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

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Copy Files Help Needed!

    Drop a FileSystemWatcher to your form and try this.

    Public Class Form1
    Private changedFiles As New List(Of String)

    VB.Net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         FileSystemWatcher1.Path = "F:\"
    3.         'I assume that you want to include the subdirectories. If not, remove the line underneath.
    4.         FileSystemWatcher1.IncludeSubdirectories = True
    5.     End Sub
    6.  
    7.     Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
    8.         If e.ChangeType = IO.WatcherChangeTypes.Changed Then
    9.             Dim filePath As String = e.FullPath
    10.             If IO.File.Exists(filePath) AndAlso Not changedFiles.Contains(filePath) Then 'This will filter out the directories and prevent duplicates from being added.
    11.                 changedFiles.Add(e.FullPath)
    12.             End If
    13.         End If
    14.     End Sub
    15. 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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width