Jump to content

Check if remote file exists


Recommended Posts

#include <file.au3>

;the file you want to search for
$find = "test.txt"

;where E: is the remote drive you want to check
$rDrive = DriveMapGet("E:") & "\"

;change the working directory
FileChangeDir( $rDrive )

;get the first file
$search = FileFindFirstFile( "*.*" )

If $search = -1 Then
    MsgBox( 0, "ERROR!", "There are no files or could not connect to remote directory" )
EndIf

While 1
    $file = FileFindNextFile( $search )
    
    If @error Then
        MsgBox( 0, "Failure", "The file was not found in the remote directory" )
        ExitLoop
    EndIf
    
    If $file = $find Then
        MsgBox( 0, "Success", "The file exists in the remote directory " & $rDrive )
        EndLoop
    EndIf
WEnd

FileClose( $search )

Hope that helps...

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

Either of these should be able to tell you, what I would say is that if the webhost displays a html "file not found" page then inetget will download this page, so I suggest you open the file and check a line of text within the file to ensure it isn't a HTML "file not found" page you just downloaded

Downloads a file from the internet using the http or ftp protocol.

InetGet ( "URL" [,"filename" [, reload [, background]]] )

Returns the size (in bytes) of a file located on the internet.

InetGetSize ( "URL" )

Link to comment
Share on other sites

If its on ur home ftp server can't you jsut run a script on the server and have it email you the size. Or map a network drive to the drive running the ftp server and run the script posted above?

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

Try this

$size = InetGetSize("http://www.comp-sos.co.uk/download/test.exe")
if $size = 0 Then
MsgBox(0, "", "File does not exist")
EndIf


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...