Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. File Synchronization/Backup

File Synchronization/Backup

Scheduled Pinned Locked Moved Visual Basic
performancequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RichardBerry
    wrote on last edited by
    #1

    I would like to create a small app to synchronize/backup various groups of files or folders between a flashdrive, home pc and work pc. Any comments to ensure good speed and reliability regarding the following would be appreciated: 1) To determine which files have changed, <pre> Dim di As New DirectoryInfo(Path) Dim files As FileSystemInfo() = di.GetFiles Dim fi As FileInfo 'Loop through files and see when last modified, and add to a datatable             For Each fi In files                         dr = dtFiles.NewRow                         dr.Item(0) = diNext.Name                         dr.Item(1) = dr.Item(0) = diNext.LastWriteTime                         dtFiles.Rows.Add(dr)          Next </pre> Is this OK, or would it be better to check CRC of the files to find the ones that have changed? I was thinking more along the lines of determining which is the NEWEST file, and then making the sync Bi-Directional though 2) Once I have found the files that are newer, then use: <pre>System.IO.File.Copy("Sourcefile", "DestinationFile")</pre> To verify file copied correctly, maybe just put above in a Try... Catch... Or should I check CRC or something to see if copied correctly? 3) If anyone has done something similar, are there any pitfalls or things I should watch out for? Tks.

    D 1 Reply Last reply
    0
    • R RichardBerry

      I would like to create a small app to synchronize/backup various groups of files or folders between a flashdrive, home pc and work pc. Any comments to ensure good speed and reliability regarding the following would be appreciated: 1) To determine which files have changed, <pre> Dim di As New DirectoryInfo(Path) Dim files As FileSystemInfo() = di.GetFiles Dim fi As FileInfo 'Loop through files and see when last modified, and add to a datatable             For Each fi In files                         dr = dtFiles.NewRow                         dr.Item(0) = diNext.Name                         dr.Item(1) = dr.Item(0) = diNext.LastWriteTime                         dtFiles.Rows.Add(dr)          Next </pre> Is this OK, or would it be better to check CRC of the files to find the ones that have changed? I was thinking more along the lines of determining which is the NEWEST file, and then making the sync Bi-Directional though 2) Once I have found the files that are newer, then use: <pre>System.IO.File.Copy("Sourcefile", "DestinationFile")</pre> To verify file copied correctly, maybe just put above in a Try... Catch... Or should I check CRC or something to see if copied correctly? 3) If anyone has done something similar, are there any pitfalls or things I should watch out for? Tks.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      2). You can use File.Copy the copy the files over, wrapped in a Try/Catch block. You don't have to check the file contents yourself since the O/S takes care of that for you. Since File.Copy is a blocking call, any errors encountered will throw an exception you can catch. 3) Yeah, but I didn't write my own system to do this. I used the MS Sync Framework[^].

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups