Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 150057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:13:47+00:00 2026-05-11T09:13:47+00:00

Ok I’ve got a bit of an interesting problem on my hands. Here’s a

  • 0

Ok I’ve got a bit of an interesting problem on my hands. Here’s a bit of background:

I’m writing a media library service implementation that will serve URLs to a front end flash player. The client wants to be able to push content into the service by uploading files with some metadata into an FTP folder – I have control of the metadata schema. The service watching this folder will pick up any new files, copy them to a ‘content’ folder with, then push the meta data and the url’s to the content down the content service and into the database.

The content service isn’t a problem, done. Watching an FTP folder is.

My current implementation uses the FileSystemWatcher object with a filter for xml files.

There may be more than one file for each content item e.g. high, med, low quality videos.

I plan to enforce either by process or by a tool that the content is organised into it’s own folders just for brevity but this isn’t really an issue.

The xml file will look a bit like this:

<media>   <meta type='video'>     <name>The Name Displayed</name>     <heading>The title of the video</heading>     <description>         A lengthy description about the video..     </description>     <length>00:00:19</length> </meta> <files>     <video file='somevideo.flv' quality='low'/>     <video file='somevideo.flv' quality='medium'/>     <video file='somevideo.flv' quality='high'/> </files>  </media> 

So when a new file is created the FileSystemWatcher.Created event fires. I’ve got a seperate thread running to process the content which shares a queue with the main service process (don’t worry it’s using the producer consumer pattern as detailed here: http://msdn.microsoft.com/en-us/library/yy12yx1f.aspx).

This all works fine, but now I’m running into edge cases left right and centre!

I’ve taken into account that the videos will take longer to upload so the processor will try to get an exclusive lock, if that fails it will move the item to the back of the queue and move onto the next item.

  • What happens if the service crashes or there’s already files there? so I wrote a method to queue up an existing files.
  • What if files are getting uploaded while it’s queueing up the existing files? Hopefully it will handle this? Should I periodically rescan the directory to see if I missed anything?

Can anyone recommend a best practice for this scenario? Is the filesystemwatcher a good idea or should the service just periodically scan the folder?

Edit: Just to give you some idea of scale. We’re talking 10s of 1000s of items in total. Probably uploaded in large chunks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:13:48+00:00Added an answer on May 11, 2026 at 9:13 am

    FileSystemWatcher is a pragmatic way of getting early visibility of a file drop, but there are a lot of edge-cases that can cause missed events. You would still need a periodic sweep to be sure.

    To avoid as many mutex issues; could the clients upload as foo.xml.upload, and then rename to foo.xml one there? That would avoid a lengthy locked file… (you just ignore the .upload ones).

    Also: beware ‘not invented here’… there are many existing utilities that monitor folders; BizTalk for (an overkill) example. I’m not saying ‘don’t do it yourself’, but at least consider pre-canned options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.