Does CFFile Read lock the file?

Posted on 2008-11-18
Last Modified: 2012-06-21

I have an .NET application which is constantly writing to a log file. I want to write a ColdFusion application that can parse that log file and determine if any errors have been recorded.

I am worried about a sharing violation. Does the ColdFusion CFFile action = "read" command place an exclusive lock on the file that would prevent the .NET application from continuing to write to it?

Any ideas? Can I make a copy of the file temporarirly and parse the copy? Or does CFfile action ="copy" have the same locking problem?

Thanks so much!
Question by:jsimonuchc
    LVL 6

    Expert Comment

    CFFILE does not put an exclusive lock on the file you want to read.  You may, however, run into a sharing violation if your .NET app is writing to the file when your CF app is reading the file.  To work around this you may want to use CFLOCK.  If .NET cannot detect and work with CF's CFLOCK, then you may want to try a work around that might work like this:

    Before CF reads log file, write an empty file "log.reading".
    Then CF can read the log file.
    CF would then delete the temp file "log.reading".

    While this is going on, before .NET writes to your normal log file, it can check to see if the "log.reading" file exists.  If it does exist, hold the log entry(ies) and check back in a X second interval.

    LVL 1

    Author Comment

    Unfortunately, I do not have access to the .NET application's code. I cannot make any changes to that application or the way it reads/writes the log file.

    the problem you are describing "You may, however, run into a sharing violation if your .NET app is writing to the file when your CF app is reading the file." is exactly what I am worried about.
    LVL 6

    Accepted Solution

    Depending on the size of the file, your best bet may be to copy the file and then read it into CF.

    There is another post that may provide you with the solution you are looking for.  Read the Accepted Solution at the bottom from black0ps

    LVL 1

    Author Comment

    alright, let me look into that and I'll let you know.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    760 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

    13 Experts available now in Live!

    Get 1:1 Help Now