Deamon in VB

I am currently writing an Unix like Deamon using VB. The program continously checks for the presence of files in a particular folder
in my C drive. How do I write the code that would specify the particular folder in my C drive and if a file exists, I want to make a copy of the file.
Thanks,
Zack
tzachariAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hatem72Commented:
' this is the first part
'btw: it will only find the first one!
'just change the code to find all
'use as:

'MsgBox FindFile("c:\", vFile$) & vFile$

Public Function FileExist(Path$) As Integer
    Dim x

    x = FreeFile

    On Error Resume Next
    Open Path$ For Input As x
    If Err = 0 Then
        FileExist = True
    Else
        FileExist = False
    End If
    Close x

End Function

Public Function FindFile(ByVal Path As String, ByVal File As String) As String
  Dim DirName As String, LastDir As String
 
  If File = "" Then Exit Function
  If Right(Path, 1) <> "\" Then Path = Path & "\"
 
  DirName = Dir(Path & "*.*", vbDirectory)
  Do While Not FileExist(Path & File)
 
    If DirName = "" Then Exit Do
    DoEvents
    If DirName <> "." And DirName <> ".." Then
      If (GetAttr(Path & DirName) And vbDirectory) = vbDirectory Then
        LastDir = DirName
        DirName = FindFile(Path & DirName & "\", File)
        If DirName <> "" Then
          Path = DirName
          Exit Do
        End If
        DirName = Dir(Path, vbDirectory)
        Do Until DirName = LastDir Or DirName = ""
          DirName = Dir
        Loop
        If DirName = "" Then Exit Do
      End If
    End If
    DirName = Dir
  Loop
 
  If FileExist(Path & File) Then FindFile = Path

End Function

0
hessCommented:
how about this... seems way easier.

Dir(path) retures the first file name that matches the querry. so dir("c:\*.exe") would return the first exe file in c:\, say , "c:\jon.exe"

now just use a timer and say

private sub Timer1_timer()
if dir("c:\the Dir Your Checking\*")<>"" then
your code here
your code here
your code here
your code here
your code here
end if
end sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hessCommented:
if there are no files in dir("c:\the Dir Your Checking\*") then dir returns ""
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.