If File Exists

4 отговора 196 прегледа
#1

If File Exists

Nqkoi moje li da kaje kak moga da pravore v VB6 dali opredelen fail sy6testvuva, ili ne???

Bлагодаря преджарително

Отговор
в отговор на vbcoder #2

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 обекта

Отговор
в отговор на Пaлячo #3

Re: If File Exists

или още по-лесно

If Dir("C:\abc.txt") = "" then
'file does not exist
else
'file exists
end if

Отговор
в отговор на microsoft #4

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

Отговор
в отговор на vbcoder #5

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


Отговор