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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory validation

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
0
16
AU
I have a remote connection to a server using a VPN

I need to validate folders when connected.

When I use the UNC path to the folder, the Directory() command hangs for about a minute if the VPN connection is not active, but returns true when connected and the folder exists

Code:
Example:

lcDir='\\192.168.1.250\SomeFolder'
IF DIRECTORY(lcDir)
[indent]return .t.[/indent]
ENDIF

Is there a better way to validate folders?
 
You *might* get better performance using fcreate() trying to create a file there, but failure wouldn't actually tell you whether the directory exists. You just might not have rights.

The long hang isn't coming from Foxpro. It's just waiting for the operating system, and Windows has a long timeout on this type of thing.
 
How long does it take if the vpn is connected but the folder does not exist?

Perhaps you could check the vpn is active first?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi Griff,
I just tested your question:
when connected to the VPN, if a folder does not exist the response time for a folder that does not exist is normal.
The issue only arises when the vpn is not connected.
So I need to validate the connection before testing for a folder.

Alastair
 
OK, further testing is as follows:
Once the connection has disconnected and windows has registered that the vpn is not connected (And the VPN adapter has changed state to 'not connected'), then directory validation returns false with no delay.
The problem lies with the time it takes for windows to register that the VPN is not connected. That period of time is when the hang occurs.
So I need a way to avoid my program from hanging if it tries to access the VPN during this disconnection period.

EDIT: The above is not correct - another test when disconnected and the DIRECTORY command hung again.


Alastair
 
I am having a look at the Windows command 'net use' which returns a list of connected networks.
I may be able to use that first to validate the connection. I will report back.
 
Hi
I am stuck with connecting to a VPN

I can start the VPN connection using rasdial.exe
But in my validation process I need to 'activate' the unc path some way. for instance if I type the path into an explorer window and push enter, or from the start menu bring up the run dialog and type the unc path and push enter, the network appears instantly in the network list, and my validation process returns true.

I am stuck on what should be a very simple process - how can I program a command in VFP to make this last step happen?
 
Can you do a shellexecute to open a window and do that?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi Griff,
I am trying, but cant seem to get that to work.
I guess the less windows that open the better, if I can activate the directory silently that would be better.
I only have used shellexecute to open default programs, so will have to have a look at it closer to make it work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top