Author Topic: FileSystemWatcher Works But Not When Monitoring IIS Mail Drop Folder  (Read 1927 times)

0 Members and 1 Guest are viewing this topic.

Bill Tillman

  • Guest
Doing some more VB.NET today and ran into this issue. My FileSystemWatcher sub works exactly how I intended but it will not work when the directory I'm trying to monitor is the C:\Inetpub\mailroot\Drop folder. I'm watching for e-mails to arrive and then the program takes action. But it's apparent there is something unique with this folder. All other folders I test works fine.

The error message show P9: system.io.ioexception

BlackBox

  • King Gator
  • Posts: 3770
Re: FileSystemWatcher Works But Not When Monitoring IIS Mail Drop Folder
« Reply #1 on: October 03, 2012, 01:34:44 PM »
Since you've not posted your code:

What are the System.IO.DirectoryInfo(Folder).Attributes for your folder?

Based on the error posted, your code does not appear to account for potential exceptions (be it using logical test expressions where possible, or a Catch block), but what is returned by ex.Message?

Code - C#: [Select]
  1.             // snip
  2.  
  3.             catch (IOException ex)
  4.             {
  5.                 ed.WriteMessage(
  6.                       "\n; error: IOException: {0} \n", ex.Message
  7.                     );
  8.             }
  9.  
  10.             // snip
  11.  
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: FileSystemWatcher Works But Not When Monitoring IIS Mail Drop Folder
« Reply #2 on: October 03, 2012, 01:54:26 PM »
Also, I do not recognize the mail client by the folder you specified... Is it possible to use a mail 'rule' to forward a copy of the incoming email to another folder that does allow you access (without changing things)?

If so, this may be the route to go, and you can incoporate a System.IO.File.Delete(File) Method call to remove the duplicate file from the supplementary directory... When done.
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6151
Re: FileSystemWatcher Works But Not When Monitoring IIS Mail Drop Folder
« Reply #3 on: October 03, 2012, 02:45:16 PM »
The Inetpub folder is from turning on IIS and for hosting websites among some other things.
 
So if you start to venture into programming for web applications and want to test it you turn on IIS and use your computer as web server and place website there.
 
Check security for read and listing

Bill Tillman

  • Guest
Re: FileSystemWatcher Works But Not When Monitoring IIS Mail Drop Folder
« Reply #4 on: October 03, 2012, 03:35:52 PM »
The workstation this is setup on is running IIS. The IT guys did that because it was their way (down and dirty) of getting the e-mail file delivered directly to this machine. And that is the method we use (for now) is an e-mail arrives and is dropped off in the C:\Inetpub\mailroot\Drop folder. My present method which uses a rather complicated batch file process to look in this folder is working. That is it gets called every 60 seconds by a Scheduled Task, if it finds a file in there it acts on it which is it reads and parses it, then sends a  headerless copy of the e-mail to another folder which the LISP program uses when it runs. After the drawing is created the email file in the Inetpub folder is moved to a location for archive purposes. All this works but I was hoping that FileSystemWatcher might be a better method...and it was working pretty darn good. I even had it making an entry in a textbox which listed who sent the e-mail, what time they sent it and a brief description of the product they were requesting. And I could turn it on and off with a button rather than having to go to Scheduled Tasks and stop it. And it wasn't popping that annoying little black box up every 60 seconds as well. But when I moved the folder to monitor to the Inetpub location, it stopped working.

Oh well, if it were all easy they could hire any bum off the street and I'd be out of work.