467,074 Members | 1,073 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

LOCK FILES

is there a 3rd party tools or simple batch scripts or VB.NET 2003 to lock
files
? Here is the problem

1. i've a config.ini FIXED in a local directory eg c:\configuration. Only
this file exist in this directory.
2. the contents of config.ini is follows

key=country_code

3. The vendor software i m using only recognise c:\configuration\config.ini
as parameters as the vendors told me that the path is hard-coded in the
above directory.

4. i've many countries and each key represents different countries. If i run
the software in many physical machines, it works because there can never be
contention of the config.ini file. However if i want to save costs and run
the program on ONE machine only, i must create a batch file or script to
check whether config.ini is currently in use. If not in use, the program can
use this file and run. If in use, wait for x minutes before re-try.

5. How shld i approach the above problem ?

Dec 2 '05 #1
  • viewed: 1538
Share:
1 Reply
In .net you could do something like this to check every minute if a file is
in use, just try to open it in a try catch block:

Dim myReader As IO.StreamReader
Dim myFile As String = "c:\configuration\config.ini"
If System.IO.File.Exists(myFile) Then
Do
Try
myReader = New IO.StreamReader(myFile)
myReader.close
'startYourProgram
Exit Do
Catch
Threading.Thread.Sleep(60000)
End Try
Loop
Else
MessageBox.Show(myFile & ": does not exist")
End If

hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"James" <jk****@hotmail.com> schreef in bericht
news:u$**************@TK2MSFTNGP14.phx.gbl...
is there a 3rd party tools or simple batch scripts or VB.NET 2003 to lock
files
? Here is the problem

1. i've a config.ini FIXED in a local directory eg c:\configuration. Only
this file exist in this directory.
2. the contents of config.ini is follows

key=country_code

3. The vendor software i m using only recognise c:\configuration\config.ini as parameters as the vendors told me that the path is hard-coded in the
above directory.

4. i've many countries and each key represents different countries. If i run the software in many physical machines, it works because there can never be contention of the config.ini file. However if i want to save costs and run
the program on ONE machine only, i must create a batch file or script to
check whether config.ini is currently in use. If not in use, the program can use this file and run. If in use, wait for x minutes before re-try.

5. How shld i approach the above problem ?


Dec 2 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Hon Seng Phuah | last post: by
2 posts views Thread by Tommy.Ryding@gmail.com | last post: by
14 posts views Thread by Gary Nelson | last post: by
4 posts views Thread by Scott Johnson | last post: by
5 posts views Thread by William Gill | last post: by
12 posts views Thread by Elmo Mäntynen | last post: by
190 posts views Thread by blangela | last post: by
6 posts views Thread by Gina_Marano | last post: by
6 posts views Thread by michael.spoden@web.de | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.