: [b][red]This message was edited by cloudncali at 2006-6-16 8:9:26[/red][/b][hr] : is there a funtion to see if a filem exsists in a folder : : if not how can i make one : I don't know if a function exists, but when you try to open an unexisting file it generates an error, so you can use this to create your own function. Try with something like this:
[code]public function ExistsFile (path as string) as boolean dim Useless as boolean Useless = true
on error goto EndOfFunction
open path for input as #1 close #1 ExistsFile = true
if Useless = false then EndOfFunciton: ExisitsFile = false end if
end function[/code]
The way it works is very simple: the function tries to open the file, if it succeed ExisitsFile is true, if not it generates an error and the function goes in a "restricted area" and ExistsFile is false.
I'm quite sure that the function can be improved, but for the moment it should work.
: : [b][red]This message was edited by cloudncali at 2006-6-16 8:9:26[/red][/b][hr] : : is there a funtion to see if a filem exsists in a folder : : : : if not how can i make one : :
you can use the DIR keyword-
[code] dim tmp as string tmp = dir("c:WINDOWSSYSTEM32CALC.EXE") if tmp<>"" then debug.print "file exists" else debug.print "file not found" end if [/code]
Comments
: is there a funtion to see if a filem exsists in a folder
:
: if not how can i make one
:
I don't know if a function exists, but when you try to open an unexisting file it generates an error, so you can use this to create your own function. Try with something like this:
[code]public function ExistsFile (path as string) as boolean
dim Useless as boolean
Useless = true
on error goto EndOfFunction
open path for input as #1
close #1
ExistsFile = true
if Useless = false then
EndOfFunciton:
ExisitsFile = false
end if
end function[/code]
The way it works is very simple: the function tries to open the file, if it succeed ExisitsFile is true, if not it generates an error and the function goes in a "restricted area" and ExistsFile is false.
I'm quite sure that the function can be improved, but for the moment it should work.
: : is there a funtion to see if a filem exsists in a folder
: :
: : if not how can i make one
: :
you can use the DIR keyword-
[code]
dim tmp as string
tmp = dir("c:WINDOWSSYSTEM32CALC.EXE")
if tmp<>"" then
debug.print "file exists"
else
debug.print "file not found"
end if
[/code]