for some reason the first time I posted this it only showd some of it, so I've reposted it.
I would like to know the code to do a "if file exist then" in visual basic. something like in a .bat file as follows. IF EXIST C:install.log ( @echo I'm here ) ELSE ( @echo Your File is missing. ) @rem @rem pause I know how to do an on Error go to but that is not what I'm wanting to do here. I just want to check if a certain file exists example If “C:remote directoryfile.txt” exist then goto that line. Any help would be greatly appreciated.
Software/Hardware used:
ASKED:
June 30, 2010 6:18 AM
UPDATED:
July 1, 2010 6:29 PM
I still don’t understand. where do I put the file name, etc.
Try this function:
Private Function Check_File(sPath As String) As Boolean If Dir$(sPath) <> "" Then Check_File = True Else Check_File = False End If End FunctionCall it this way:
Where do I put the Private function at, declaratons? or on it’s on page?
Ok. I’ve done as you stated but to no avail. Please clarify if you will. Thank you.
Hi TheFinder.
Actually, you should call the function provided by Vatchy this way:
(Replacing <your_fllename> with the name of the file you want to check).
Sorry, major brain fart. Carlosdl is correct about how to call it. Replace the last two lines I gave you (Dim and If) and replace with his example.
Thank you, it’s now working, but is there a way to have it check and not show the file and path to file in a msgbox before it replies to true or false.
Thank you both Vatchy and Carlosdl,
It was my bad, yesterday on debugging I had told it to msgbox me and today I forgot that line was there, it’s now working as expected. you rock.