Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Check if 2 files exist

I am making a registration module that compare 2 files contents
i have a Boolean function that checks if files exist
    Dim sFileOneExists As Boolean
    Dim sFileTwoExists As Boolean

sFileOneExists = FileExists(sFileNameOne)
sFileTwoExists = FileExists(sFileNameTwo)

whats the best way to write this ?
if neither exists then they are created
if only one exists then the program has been hacked
if they both exist then they are opened and compared
using vb6
  • 2
  • 2
1 Solution
That can be done using the FileSystemObject model in VB6.

See this: Link

P.S. If I get a chance I might write some of the code to check for the files, but I can't guarantee anything.

Hope it helps.
Martin LissRetired ProgrammerCommented:
    Dim sFileOneExists As Boolean
    Dim sFileTwoExists As Boolean
    On Error Resume Next
    sFileOneExists = (GetAttr("Path and file name 1") And vbDirectory) = 0
    sFileTwoExists = (GetAttr("Path and file name 2") And vbDirectory) = 0

    On Error GoTo 0
    Select Case True
        Case Not sFileOneExists And Not sFileTwoExists
            MsgBox "create files"
        Case sFileOneExists And sFileTwoExists
            MsgBox "Compare"
        Case Else
            MsgBox "Hacked"
    End Select

Open in new window

isnoend2001Author Commented:
LIONKING, not looking for file open, save or exists
isnoend2001Author Commented:
thank you MartinLiss, just what i needed
Martin LissRetired ProgrammerCommented:
You're welcome and I'm glad I was able to help.

My profile contains links to some articles I've written that may interest you.
Marty - MVP 2009 to 2012

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now