If File Exists
4 отговора
196 прегледа
If File Exists
Nqkoi moje li da kaje kak moga da pravore v VB6 dali opredelen fail sy6testvuva, ili ne???
Bлагодаря преджарително
Bлагодаря преджарително
Re: If File Exists
Function ReportFileStatus(filespec)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
ReportFileStatus = msg
End Function
и въобще обърни внимание на FileSystemObject обекта
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
ReportFileStatus = msg
End Function
и въобще обърни внимание на FileSystemObject обекта
Re: If File Exists
или още по-лесно
If Dir("C:\abc.txt") = "" then
'file does not exist
else
'file exists
end if
If Dir("C:\abc.txt") = "" then
'file does not exist
else
'file exists
end if
Re: If File Exists
Blagodarq, sega 6te go probvam!
No mislq 4e tova s FileSystemObject ne e uda4no, az tova go znam no logi4no be6e da ima i po lesen na4in
No mislq 4e tova s FileSystemObject ne e uda4no, az tova go znam no logi4no be6e da ima i po lesen na4in
Re: If File Exists
Ima i oshte edin nachin!

Public Function IfExist(f As String) As Boolean
On Error Resume Next
Open f For Input Access Read As #1
If Err.Number = 0 Then
IfExist = True
Close #1
Else
IfExist = False
End If
End Function