?
Solved

Autosending a file. Very urgent!

Posted on 2003-03-19
7
Medium Priority
?
156 Views
Last Modified: 2010-05-01
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.
0
Comment
Question by:Xiaosi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Accepted Solution

by:
supunr earned 1600 total points
ID: 8171486
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
 
LVL 2

Expert Comment

by:dhenson
ID: 8171903
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
 

Author Comment

by:Xiaosi
ID: 8200913
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
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.

 
LVL 11

Expert Comment

by:supunr
ID: 8206785
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
 

Expert Comment

by:CleanupPing
ID: 8531962
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
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8958667
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question