Quantcast
Channel: Classic ASP
Viewing all articles
Browse latest Browse all 488

How to Poll Server for existence of file

$
0
0

Need to know if file exists on server.

Client program needs this info to proceed.

Tried FTP code in client program to loop and continually check for existence of file but is consumes bandwidth and ties up client processor.

Decided that client would call an asp and the asp would try for 10 seconds and send results back to client.

see code below;

<html><body><%
	serial=request.Querystring("Serial")
	Set fso = CreateObject("Scripting.FileSystemObject")
	starttime=timer
	filefound=false
	do while timer<starttime+10	'10 second delay
			if timer<starttime then exit do ' Midnight reset
			if fso.fileExists( server.mappath("\") &  "\data\trims_net\" & serial & "\command.txt" ) then
			FileFound=true
			exit do
		end if
	loop
	if filefound then
		response.write( "FileFound")
	else
		response.write("TimeOut")
	end if

	Set fso = Nothing
 %></body></html>

Above code works BUT now I'm consuming server processing time -due to fact that I'm now in a loop on server or up to 10 seconds on each request.

I need a better way - any suggestions?

Lee


Viewing all articles
Browse latest Browse all 488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>