Jump to content
Sign in to follow this  

Determining if a file is in use

Recommended Posts

Forgive me if this is question is somewhat basic, but here's the deal:

I have two computers that are networked together. If the first computer (named "main") has a file open and the second computer tries to open the file like so -

$File = FileOpen("//main/inv.txt",2)
$FileWriteLine($File,Price[5] & "," & Price[6])

I get an error. I think that when the "main" computer has this file open (which will be the case sometimes and there's no way around that) I get the error:

AutoIt Error

Line 0 (File "C:\bot.txt"):

$FileWriteLine($File,Price[5] & "," & Price[6])

Error: Invalid File Handle used

I have searched the helpfile for a solution and haven't found a specific function to use, but basically I need a way to tell if another user has this file open. Does AutoIt Have this capability or something in the works? Or is there an easy fix that I'm just not thinking of?

Any help is greatly appreciated, thanks. BTW, AutoIT rocks - I have been able to learn it fairly quickly and have done some pretty cool stuff with it.


Edited by bradley1

Share this post

Link to post
Share on other sites

Look at the example of FileOpen in the Helpfile. The example shows use of error checking to help eliminate problems.

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")



:whistle: Edited by MHz

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...