[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

monitoring a file

Hello,
I have create a windows service that monitor all the files that are created in a specific directory when a new file is creted I call an application api that will load the new file, the problem that ,I,m having is that is the file.still open by other application i will not  be able to upload the file to my api, Im looking a way to get to know when a file ia not more used by any other app so i can call my api
0
cano63
Asked:
cano63
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Just add the file to a queue and periodically attempt to process the file(s) from a Timer.  You can attempt to open the file in "exclusive" mode (FileShare.None) and catch the exception:
http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now