PDA

View Full Version : Check if file over network is in use?



arrigob
03-16-2011, 08:19 AM
Hi there,

In our software, you run the program locally and pull data from another area on the network. We want to make sure that no users are working in our software when they run one of our updates. We have a file labeled fpuser.dat that would be in use if at least one person is signed in to our program. The only problem is that the fpuser.dat file is located on the network and not locally. Is there a way to check and see if the file is in use on a network?

If this is not possible, do you know of a way to accomplish something like this. We are worried that a user being logged in during an update that includes dictionary changes could be harmful to their data files. Any help would be wonderful. Thanks, as always!

Brandon

linder
03-16-2011, 08:57 AM
Brandon,

Does the "Check In-use File..." function not work in your case?

I checked the following:

Set Variable %INUSE% to FUNCTION:Check In-use File "\\Win7-64\Corpdata\test.dat"

The 'test.dat' file was located on another machine and was locked (in-use) and the function returned '1'.

Friedrich

arrigob
03-16-2011, 09:36 AM
Hey,

I return a -1 when using that function. I am also telling it to check %DATAPTH%\fpuser.dat. Is that my problem. I do not know what the end users network path will be but I do know that this variable will always have the path to the shared data folder on their network.

Brandon

linder
03-16-2011, 09:45 AM
Brandon,

'-1' means "File not found" here. That means, you point to an incorrect file location.

Friedrich

linder
03-16-2011, 09:48 AM
BTW, and if this is a mapped drive on an UAC-aware operating system, make sure that the mapped drive is 'accessible' by your process.

http://www.lindersoft.com/forums/showthread.php?t=31410

Friedrich

arrigob
03-16-2011, 09:48 AM
? That is weird.

I also just tried the same function but this time I told I used the actual network path \\server2900\fpa\fpuser.dat. This also returned -1, but I can physically see the file in that location? Any ideas, I'm still playing with it too.

arrigob
03-16-2011, 09:55 AM
Just saw your last post, I am going to play around on that. I am using a Windows 7 machine to connect to a windows 2003 server.

linder
03-16-2011, 09:59 AM
It's very simple. The CreateFile Windows API to open the file returns INVALID_HANDLE_VALUE. That means the \\server2900\fpa\fpuser.dat file is not available (file not found) or the network share is not accessible (in fact, that also means 'file not found').

Just for fun, try the "If File/Folder..." script function to check if the file exists and I am sure you'll get the same result.

Perhaps a permission problem!?

Friedrich

linder
03-16-2011, 10:02 AM
Assuming that the file/folder information is correct, it's a permission problem (IMO)

Friedrich