How to check a file at client side

M

mhadi

Hello
Please Help me!! The big bossman is screaming in my ear,
I am only devloper of dotnet in my software house and know only to develop
widows based application !!

My boss wan't me to devolope a page so that when a user clicks a link to to
download a file the page check directory at client side(fixed lets name it
"c:\download") and search for file say "blablav1.1.exe" (version will be
updated)

if file is found then
dont download it
else if it is not then
download the new version and execute it to install

waiting for quick rescue
mhadi
 
S

Scott M.

It's no problem to check the client side file system if your clients will be
IE, you can use the VBScript "FileSystemObject" to check if the file is
there or not.

The problem is using the client to cancel the download that has already
begun at the server level.

You might want to try having the link point, not to the file for download,
but to a page that consists of nothing but the code that will check to see
if the user already has the file. If they do, the page can redirect them
back to where they came from without doing anything and if they don't, the
file can redirect them to a page that sends the file down to them.

Check here for info. on using the FSO (also look at the methods link for the
"FileExists" method that you will need):

http://msdn.microsoft.com/library/d...en-us/vbenlr98/html/vaobjfilesystemobject.asp
 
S

Scott M.

Here's an old example I dug up...

<HTML>
<HEAD>
<title>Using the FileSystem Object</title>
</HEAD>

<BODY>
<SCRIPT LANGUAGE="VBScript">
Dim fso, myFile

Set fso = CreateObject("Scripting.FileSystemObject")

if fso.FileExists("c:\VBScript.txt") then
'The number 8 represents the 'ForAppending' constant
'The 'True' argument says to create the file if it doesn't exsist
'but in this example, it doesn't matter because we are inside of the
'true condition that tests if the file exists anyway
set myFile = fso_OpenTextFile("c:\VBScript.txt",8, True)
myFile.WriteLine(inputbox("What would you like in your text file?"))
myFile.WriteLine(date & " - " & navigator.appName)
myFile.Close
end if

'***************************************************************************
*********

Dim Drive, AllDrives
Set fsObj = CreateObject("Scripting.FileSystemObject")
Set AllDrives = fso.Drives

For Each Drive in AllDrives

document.write (Drive.DriveLetter & " - ")

If Drive.DriveType = 3 Then 'Network Drive
document.write (Drive.ShareName)
ElseIf Drive.IsReady Then 'Removable Media with Media Present
document.write (Drive.VolumeName)
End If

document.write("<BR>")
Next

Set myFile = nothing
Set Drives = nothing
set fso = nothing
</SCRIPT>
</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top