1

Hi I have a C# Windows Service installed on a server.

On the other side, the service starts a timer that will read files from a network folder.

My customer requires that a fixed length file is created on a network folder, then they have a process that will do some stuff to the file and in case of success the file is deleted but in case of an error the same file but with extension .err is created.

I know that there are Windows API's that its possible to trigger an event every time a file is created, the thing is that this folder is not on the same server where the service is running.

Is that possible? Mapping the folder into the server will do the trick?

VAAA
  • 14,531
  • 28
  • 130
  • 253
  • 1
    Why don't you try it? – Dave Zych Nov 04 '13 at 19:23
  • It would probably be better to use the `FileSystemWatcher` that's available via the .NET Framework rather than leveraging Windows API's. – Mike Perrenoud Nov 04 '13 at 19:27
  • I suppose you're talking about filesystemwatcher when you are saying API's. You would need it to run on a UNC path. Take a look at this post http://stackoverflow.com/questions/960318/filesystemwatcher-fails-to-access-network-drive – Bearcat9425 Nov 04 '13 at 19:28

1 Answers1

1

The FileSystemWatcher class in .NET will use the appropriate Windows change notification APIs, and the SMB 2.0 protocol supports change notifications that get delivered via the Windows change notification APIs.

So, if the remote server supports SMB 2.0 (Windows Server 2008 or above, Unix hosts running Samba 3), then the FileSystemWatcher class should do the trick.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71