Sync files to database

Last post 11-05-2009 1:27 PM by WilliamSnell. 2 replies.

Sort Posts:

  • Sync files to database

    10-29-2009, 6:26 PM
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 1:47 PM
    • Glendale, AZ
    • Posts 224

    The application I'm currently working on allows users to upload files to a work directory. Unfortunately, they also need to be able to manually open the directory and manipulate files. The file structure is reflected in the database, which comes to the problem. I need the database and the file system to have the same info, so I'll need to sync the database each time a user makes certain changes (move, delete, new, etc.). I'm not in the least sure how to do this. Any ideas?

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
  • Re: Sync files to database

    10-30-2009, 4:02 AM
    Answer
    • Star
      8,658 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,627

    You could create a Windows Service that continuously monitors the folder in question and synchronizes with the database whenever a change is triggered. Check out the FileSystemWatcher class here, http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Sync files to database

    11-05-2009, 1:27 PM
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 1:47 PM
    • Glendale, AZ
    • Posts 224

    Thanks, that appears to be exactly what I needed. One of my coworkers told me they'd had issues with the FileSystemWatcher in the past reporting the wrong events, but all my tests came out as expected. 

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
Page 1 of 1 (3 items)