473,625 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Robust solution for processing files in a folder

Hello,

I am writing an application that processes xml files that are stored in a
folder. The application picks up the files in a folder, processes them and
then deletes them.

What is the best approach on loading the xml files from the folder into my
application?

At the moment I am using the System.IO.FileS ystemWatcher to monitor files
that are created in the folder (created is same as copied to) and then I add
the filename to a Queue object. This has as drawback that if files are in the
folder before the application is started I have to load the into my
application manually.

If I have to write code to load the files that are already in folder before
the FileSystemWatch er becomes active, why would I even use the
FileSystemWatch er? I could use a timer and scan the directory on every
Timer.Elapsed.

I need a robust solution for 'monitoring' a folder and processing the files
in a Windows Forms application.

Philip Wagenaar
Nov 21 '05 #1
1 1423
> I need a robust solution for 'monitoring' a folder and processing the files
in a Windows Forms application.


I would use both FileSystemWatch er and a Timer. I would arrange for the
FileSystemWatch er to enable the Timer with interval=1 (ie an immediate tick)
whenever it sees the kind of change you want. I would arrange for the Timer
tick code to process all files it finds in the folder. If the Timer tick
code finds nothing in the folder, increase the interval up to a maximum,
something like:
interval *= 10
if interval >10000 then interval = 10000 ' 10 sec max
If the Timer tick code finds at least one file in the folder, decrease the
interval:
interval = 1

This design achieves the following. When no files are arriving, you will be
lightweight. When no files are arriving, you will periodically take a peek
at the folder anyway, and thus you are robust in the event of a
FileSystemWatch er failure. When files are arriving, you will get them all
without fail every time. FileSystemWatch er use is as simple as it can be, ie
when event tweak a timer, and nothing else.

In case you haven't noticed, I have some mistrust of FileSystemWatch er. I
believe its underlying technology is api ReadDirectoryCh angesW, and some
years ago I had some difficulties with its reliability. Today, perhaps my
mistrust is unwarranted, but old attitudes are hard to change.

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1385
by: rom | last post by:
i know it's not exactly the place to post this question but i didn't find a betrer group. when i send a zipped folder with an asp.net application i cant use it on the destination computer. when i open the solution i cant see the vb.net files. they appear with a yellow ! sign on them.
7
4849
by: Larry Woods | last post by:
I don't see the pattern. I have a couple of solutions that I acquired from someone else. When I load these, I see the .vbproj and .vbproj.user files in the Solution Explorer. BUT, when I create a solution, I don't see them--even though they are in the folder, naturally. What's the trick? Thanks. Larry Woods
2
2294
by: John Kotuby | last post by:
Hello all, Note: This is the full version of a Post that I inadvertently sent before it was complete. About a year ago I wrote a VB.NET 2003 solution that consists of a number of assemblies (1 EXE and 15 DLLS). As I recall, in order to deploy the solution to a testing server I simply copied the contents of the Bin folder in the development area where the compiled assemblies reside. Be patient with me here, because I haven't used...
1
1064
by: Uriah Piddle | last post by:
Hi Gang, I posted this problem a few days ago and reported it solved but it appears that I was a bit hasty in declaring victory. The problem is this: when I create a new website in VS 2005 Standard, VS makes two folders called <project name>(1) and <projectname>(2) and puts the .sln and .suo files in the (2) folder and all the rest in the (1) folder. I thought I had this licked by re-installing VS but then I changed the default directory...
2
2136
by: cashdeskmac | last post by:
Why is it that when I create a new web application, the project folder containing the webform, web.config and csproj files appears in C:\inetpub\wwwroot, yet my .sln and .suo files appear in another folder in My Documents\Visual Studio Projects? Is this normal, or have I somehow made an inadvertant change somewhere?
3
2154
by: Manikandan | last post by:
Hi, I'm copying projects from a solution in the vss. In my local system i created solution ,added that project(make modification related to solution) When i added this solution to vss, projects are referred to the original solution not from my new solution I will explain more clearly i have project folder in vss(v4.5) v4.5(folder) project1(project)
1
1761
by: Blau | last post by:
While trying to learn from some sample projects i'm running into a problem. The setup that I have is One Solution with two projects. (usually a library that is being developed along side an application.) In the examples that I am learning from, they have a "content" folder in the library solution, which stores various things like font files. In the examples, the application project does not have its own folder with the same content,...
0
1134
by: tshad | last post by:
I have a filewatcher program that is working syncronously (which is how I want it to work). But my program will handle whatever files are in the folder at the time it runs. So when I drop 15 files in the folder at once, the event kicks of 15 times - even though all the files were processed in the 1st event. This is fine, it just won't find any files in the folder for 14 times. But if I drop 600 files in the folder at once, it will...
3
5001
by: Andrus | last post by:
C# 2008 Express folder tree for one solution contains .cs and other files which are not referenced by solution. How to find those dangling files ? There are large number of files and folder is solution so manual compare takes very long time. Andrus.
0
8253
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.