Prikazi cijelu temu 20.01.2021 21:57
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Re: Application.FileSearch
Na osnovu onoga sto si dao tebi treba da provjeris dali fajl postoji u nekom dir.
Ako sam u pravu evo rjesenje.
Ovu funkciju stavi u neki modul.
PreuzmiIzvorni kôd (Visual Basic):
  1. Function FileExists(Putanja As String, Optional ImeFajla As String) As Boolean
  2. On Error GoTo Error_Handler
  3. Dim Fajl As String, PathStr As String
  4.  
  5.  If Right(Putanja, 1) = "/" Or Right(Putanja, 1) = "\" Then
  6.  PathStr = Putanja & ImeFajla
  7.  Else
  8.   PathStr = Putanja & "/" & ImeFajla
  9.  End If
  10.         If Dir(PathStr) <> "" Then
  11.            FileExists = True
  12.            Exit Function
  13.         End If
  14.  
  15. Error_Handler_Exit:
  16.     On Error Resume Next
  17.     FileExists = False
  18.     Exit Function
  19.  
  20. Error_Handler:
  21.     MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
  22.             "Error Number: " & Err.Number & vbCrLf & _
  23.             "Error Source: DirFajl" & vbCrLf & _
  24.             "Error Description: " & Err.Description, _
  25.             vbCritical, "An Error has Occured!"
  26.     Resume Error_Handler_Exit
  27. End Function

funkciju pozivas:
Dim a as boolean
a=FileExists("d:/temp","SYS.MDW")
Vraca true ako ima a false ako nema fajla
Podrška samo putem foruma, jer samo tako i ostali imaju koristi od toga.