• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1194
  • Last Modified:

Does CFFile Read lock the file?

Hi,

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!
0
jsimonuchc
Asked:
jsimonuchc
  • 2
  • 2
1 Solution
 
reitzenCommented:
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.

HTH
0
 
jsimonuchcAuthor Commented:
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.
0
 
reitzenCommented:
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

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_21459109.html


0
 
jsimonuchcAuthor Commented:
alright, let me look into that and I'll let you know.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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