Autosending a file. Very urgent!

I would like to make a program. When a file is created in folder A, it would auto send the file to another computer named rf25, desktop folder.

Let's say when the visual basic program is running, and a file is created in folder A, it would auto send that file to another computer named rf25 in the desktop folder. This means the program also need to scan the folder A continuously for any file to be created.

Hope someone can help me write the program code soon as I really need this program urgently. Thank you.
XiaosiAsked:
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.

supunrCommented:
May be this might help.  Add a timer control to the form called timer1 and set the interval to 60000 (60 sec). then use code similar to below.

Option Explicit

Private DirListing As String

Private Function CopyFileAuto()
    Dim FolderName As String
    Dim FileName
    Dim CopyDirecory As String
    Dim DirNewListing As String
   
    FolderName = "C:\"
   
    copydirectory = "\\rf25\Windows\Desktop\" ' desktop folder of the network computer
   
    FileName = Dir(FolderName & "*.*")
    DirNewListing = ""
    Do While FileName <> ""
        DirNewListing = DirNewListing & "|" & FileName
        If (InStr(0, DirListing, "|" & FileName) = 0) Then ' file not found in the previous listing, possibly a new file
            FileCopy FolderName & FileName, copydirectory & FileName
        End If
        FileName = Dir
    Loop
    DirList = DirNewListing
End Sub

Private Sub Timer1_Timer()
    CopyFileAuto
End Sub

Good Luck!
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
dhensonCommented:
The above answer by supunr would work (from the breif time i spent looking at it) if the source folder and target directory are modified to fit your situation.

I.E. Change:

Foldername="C:\"
to the folder that you want to monitor for changes (make sure you keep a "\" at the end of your string)

also, change:
copydirectory = "\\rf25\Windows\Desktop\"
to a valid UNC path on the remote computer... I.E.
copydirectory = "\\rf25\c$\documents and settings\All Users\desktop" assuming of course that the target computer is a win2k box.

later...
0
XiaosiAuthor Commented:
It says variable not defined and Private Function CopyFileAuto() was highlighted. and what you mean is a win2k box. My target computer is using win 98.

Hope you will help me regarding this problem
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

supunrCommented:
here is the updated "bug free" code.

Option Explicit

Private DirListing As String

Private Sub CopyFileAuto()
   on error resume next ' just continue if a file can not be copied
   Dim FolderName As String
   Dim FileName As String
   Dim CopyDirecory As String
   Dim DirNewListing As String
   
   FolderName = "C:\"
   
   CopyDirecory = "\\rf25\Windows\Desktop\" ' desktop folder of the network computer
   
   FileName = Dir(FolderName & "*.*")
   DirNewListing = ""
   Do While FileName <> ""
       DirNewListing = DirNewListing & "|" & FileName
       If (InStr(1, DirListing, "|" & FileName) = 0) Then ' file not found in the previous listing, possibly a new file
            If (DirListing <> "") Then  ' do not copy if this is the first time
                FileCopy FolderName & FileName, CopyDirecory & FileName
            End If
       End If
       FileName = Dir
   Loop
   DirListing = DirNewListing
End Sub

Private Sub Timer1_Timer()
   Call CopyFileAuto
End Sub

' I have change the code slightly so that when you first go to CopyFilesAuto function, it simply remember all files rather than copying all the files in the directory.

Good Luck!
0
CleanupPingCommented:
Hi Xiaosi,
This old question (QID 20556893) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Accept supunr's comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.