Checking to see if a file is in use

Posted on 2012-09-20
Last Modified: 2012-09-20
I am using filewatcher to watch a specific directory for new files.  Once a new file is created I can fire off a procedure but I want the procedure to wait unti the file is no longer in use.  Wether that means being copied or created.  I know in c# the "isfileinuse" is available does anyone know of anything like that for
Question by:rxresults
    LVL 83

    Assisted Solution

    I am not aware of any IsFileInUse function in C#. You would have to try to open the file and handle the exception if its in use.
    LVL 74

    Accepted Solution

    I'm not aware of that function in C# either. I think if you saw it posted somewhere, then it is a user-created function and not something that is inherent to the Framework.

    I also agree with CodeCruiser with regard to catching the exception.

    Author Closing Comment

    Thanks guys.  I thought that was too easy.
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    I think the points should all go to CodeCruiser. He answered the question; I was just agreeing with him  : )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now