Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to test for open file condition.

Status
Not open for further replies.

kywbdave

Programmer
Oct 27, 2004
4
US
Using this portion of script recommended in the forum:
----------------------
logfilespec="c:\vbs\file1.txt"
set ots=fso.opentextfile _
(logfilespec,8,false) 'forappending
if err.number<>0 then
wscript.echo "File is open. : err.clear
else
wscript.echo "File is not open."
ots.close
end if
-------------------------
err.number always returns 0, regardless of whether the file is open or not. I have opened the text file with various editors.
Is there a way to accurately test the text file's state?
Thanks
 
Hello kywbdave,

I don't think it is meant to be universal test for availability (or being opened by other application, in some context) of certain file. You should check what said in the source and in that particular context.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top