Can someone tell me how I can check for a file at a specified drive address 
Author Message
 Can someone tell me how I can check for a file at a specified drive address

I need to know if it is possible to check for a specific file at a specific
address IE: "d:\help\help.hlp"

This file will always be the same I just need to check to make sure it is
there and if not then handle it via an error routine

Thanks

DP



Fri, 30 Jun 2000 03:00:00 GMT  
 Can someone tell me how I can check for a file at a specified drive address

DP-
        This routine could be better, but it
works for me.
                                Joe
__________snip_________________________
Public Function FileExists(ByVal szFileName As String) As Boolean
    Dim AttrRet%
    On Error Resume Next
    AttrRet = GetAttr(szFileName)
    If Err.Number Then
        Err.Clear
        FileExists = False
    Else
        FileExists = True
    End If
End Function

--
***********************************************************

Microsoft Developer MVP- Visual Basic
"The unity of freedom has never relied on
uniformity of opinion."  (John F. Kennedy)
**********************************************************
PS- Please reply to the newsgroup- except in the
case of flames, insults, etc. (Don't bother.)



Quote:
> I need to know if it is possible to check for a specific file at a
specific
> address IE: "d:\help\help.hlp"

> This file will always be the same I just need to check to make sure it is
> there and if not then handle it via an error routine

> Thanks

> DP



Fri, 30 Jun 2000 03:00:00 GMT  
 Can someone tell me how I can check for a file at a specified drive address

Forgive me for my simplistic mindset but wouldn't the Dir() function work
just a bit better?

Public Function FileExists(szFileName as String) As Boolean
    If Dir(szFileName) <> "" Then FileExists = True
End Sub

Mark Bappe
PanAmSat Corp

Quote:

>DP-
> This routine could be better, but it
>works for me.
> Joe
>__________snip_________________________
>Public Function FileExists(ByVal szFileName As String) As Boolean
>    Dim AttrRet%
>    On Error Resume Next
>    AttrRet = GetAttr(szFileName)
>    If Err.Number Then
>        Err.Clear
>        FileExists = False
>    Else
>        FileExists = True
>    End If
>End Function



Sat, 01 Jul 2000 03:00:00 GMT  
 Can someone tell me how I can check for a file at a specified drive address

Mark-
        As I said, my routine could use some
improvement, but it works for me in the place
where I needed it. For example, it returns true
for directories- doesn't really bother me, though.
There is a difference in the two routines, though.
Paste this code into a form with a Button on it and
run the proggy.
                                        Joe
_____________snip__________________________
Option Explicit

Private Sub Command1_Click()
    Dim bRetVal         As Boolean
    Dim bRetVal1        As Boolean
    bRetVal = FileExistsMark("c:\io.sys")
    bRetVal1 = FileExistsJoe("c:\io.sys")
    Debug.Print "FileExistsMark " & bRetVal
    Debug.Print "FileExistsJoe " & bRetVal1
End Sub

Public Function FileExistsMark(szFileName As String) As Boolean
    If Dir(szFileName) <> "" Then FileExistsMark = True
End Function

Public Function FileExistsJoe(ByVal szFileName As String) As Boolean
    Dim AttrRet%
    On Error Resume Next
    AttrRet = GetAttr(szFileName)
    If Err.Number Then
        Err.Clear
        FileExistsJoe = False
    Else
        FileExistsJoe = True
    End If
End Function
________snip___________________________________

--
***********************************************************

Microsoft Developer MVP- Visual Basic
"The unity of freedom has never relied on
uniformity of opinion."  (John F. Kennedy)
**********************************************************
PS- Please reply to the newsgroup- except in the
case of flames, insults, etc. (Don't bother.)



Quote:
> Forgive me for my simplistic mindset but wouldn't the Dir() function work
> just a bit better?

> Public Function FileExists(szFileName as String) As Boolean
>     If Dir(szFileName) <> "" Then FileExists = True
> End Sub

> Mark Bappe
> PanAmSat Corp


> >DP-
> > This routine could be better, but it
> >works for me.
> > Joe
> >__________snip_________________________
> >Public Function FileExists(ByVal szFileName As String) As Boolean
> >    Dim AttrRet%
> >    On Error Resume Next
> >    AttrRet = GetAttr(szFileName)
> >    If Err.Number Then
> >        Err.Clear
> >        FileExists = False
> >    Else
> >        FileExists = True
> >    End If
> >End Function



Sat, 01 Jul 2000 03:00:00 GMT  
 Can someone tell me how I can check for a file at a specified drive address

Hello Joe,
  Very, Very true.  I wasn't really stating that there was anything wrong
with the code, I just figured one line without error handling could be a
little more simplistic for the person <VBG>.  You could still do it in one
line though.

If Dir(szFileName, 30) <> "" Then FileExistsMark = True

This is a catch all, and you could setup this function for any of the
attributes that you want to find, by passing the attribute that you want to
the function :)  IE If FileExistsMark("MyFile", 30) for all attributes.

Enjoy Joe, and once again just being VERY simplistic.

Mark Bappe
PanAm Satellite Corp

Quote:
>Mark-
> As I said, my routine could use some
>improvement, but it works for me in the place
>where I needed it. For example, it returns true
>for directories- doesn't really bother me, though.
>There is a difference in the two routines, though.
>Paste this code into a form with a Button on it and
>run the proggy.
>Public Function FileExistsMark(szFileName As String) As Boolean
>    If Dir(szFileName) <> "" Then FileExistsMark = True
>End Function



Sun, 02 Jul 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Cans access2.0 engine access btrieve files?

2. How do I create a canned form?

3. Canned AcctReceivable Module needed!

4. Canned pages....

5. Crystal Reports Canned Code

6. Canned objects and/or images

7. Switching from inhouse software to canned package.

8. line graph in vb (canned routine)

9. 'Canned' data in VB program

10. Looking 4 Canned Control

11. Can someone please tell how can i run a msi file

12. Specifying an e-mail address or Reply To address when sending mail

 

 
Powered by phpBB® Forum Software