Re: Replacement of FileExists method

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ken Halter (Ken_Halter_at_Use_Sparingly_Hotmail.com)
Date: 04/05/04


Date: Mon, 5 Apr 2004 11:12:48 -0700

Here's the method I use....
'================
Option Explicit

Private Sub Form_Load()
   If FileExists("C:\Temp\Test.txt") Then
      MsgBox "It's there"
   Else
      MsgBox "It's not there"
   End If
End Sub

Private Function FileExists(FileName As String) As Boolean
   On Error Resume Next
   If Len(FileName) > 0 Then
      FileExists = ((GetAttr(FileName) And vbDirectory) = 0)
      Err.Clear
   End If
End Function
'================

Here's an "API Way" to do it... the API's probably more reliable for
hidden/system files (not sure, haven't tried)

An API 'FileExists' Routine
http://vbnet.mvps.org/index.html?code/fileapi/fileexists.htm

-- 
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
"Syed Zeeshan Haider" <szhatforumsNoVirusesOrSpam@hotpop.com> wrote in
message news:O%23DgeQzGEHA.3880@TK2MSFTNGP10.phx.gbl...
> Hello Experts,
> I have VB6EE on Win98SE.
>
> After realizing that FileSystemObject can disturb a sleeping dog known as
> anti-virus, I have decided to abandon it completely.
> But there is a method of FileSystemObject, which I use extensively and
that
> method is FileExists.
> In search of a replacement of FileExists, I have come to following links:
>
> http://www.vb-helper.com/howto_check_file_exists_four_ways.html
>
> ...and...
>
> http://www.vb-helper.com/howto_see_if_file_exits_and_time_modified.html.
>
> But the ways written on these pages don't seem to me "solid".
>
> Are there any other ways to check if a file exists?
> What do the non-FSO professionals do to find if a file exists or not?
>
> Thank you,
> --
> Syed Zeeshan Haider.
> http://szh.20m.com/
> http://gomusharrafgo.20m.com/
>
> -----------------------------------
> Allah says to Mankind:
> "Then which of the favours of your Lord will ye deny?"
>
>


Relevant Pages

  • Re: No Error and nothing happens!
    ... An error (exception) is when a program executes an impossible instruction, ... > Private Sub Page_Load(ByVal sender As System.Object, ... Private Function GetMenuDataSetAs ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Image scaling (sign taken from a Pc Pen)
    ... > ByRef lpvBits As Any, ByRef lpBI As BitmapInfo8, ByVal uUsage As Long) ... > Private Sub Form_Load ... > Dim SrcData() As Byte, SrcScan As Long, SrcOff As Long ... > Private Function MinAs Long ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Search device for files...
    ... > only display those subdirectories that have media files. ... > issue with this running on Pocket PC Chinese versions. ... > Private Sub PopulateTreeView(ByVal Node As TreeNode, ... > Private Function CheckPathForMediaAs Boolean ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Search device for files...
    ... >> issue with this running on Pocket PC Chinese versions. ... >> Private Sub PopulateTreeView(ByVal Node As TreeNode, ... >> Private Function CheckPathForMedia(ByVal dir As String) As Boolean ...
    (microsoft.public.dotnet.framework.compactframework)