Still working on this [insert stream of invective here] project.
What I have working: I have a service that uses FileSystemWatcher on an
"in box" folder. When a text file appears in the in-box, it copies the
file to a work folder, processes it a bit, goes through a list of rules
and applies the first one that fits. Based on the applied rule, the file
can be printed, copied or deleted, or a user can be sent an email
notification.
I ran in to a problem where FileSystemWatcher receives a notification
and begins the above process, but the file has not been completely
released by the system (usually because it has not finished being
written.) I've inserted some delays but I need for the delays to
eventually give up and go on to the next file, if any. As a result, I
occasionally get files that have been orphaned, where the service timed
out and so left them in the in-box. I can deal with these manually by
restarting the service; it was written to deal with any text files in
the in-box during the startup event.
Enter threading. My thought was to spawn a worker thread for each file,
which could wait indefinitely until the file becomes available. Threads
are spawning properly, but when they get to the command to move the file
in to the working folder.... UnauthorizedAccessException, "Access to the
path is denied." Then the threads end properly. The one problem seems to
be the security context of the worker thread. This error appears both
when a file is written to the in-box and when there is a file in the
in-box on server startup.
I have both the in-box and the worker folder set so that "Everyone" has
full control over the folders, subfolders and files. I am running the
service as LocalService, which has full control over the folders,
subfolder and file. My every effort to find out the security context of
the worker thread has been baffled by (surprise, surprise) piss poor
documentation. Any help would be much appreciated.
Particulars: VS.NET 2.0, VB programming language, XP sp 2 operating
system
--
Gregory Gadow
te******@serv.net