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

x
?
Solved

Autosending a file. Very urgent!

Posted on 2003-03-19
7
Medium Priority
?
157 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
6 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

581 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