Xiaosi
asked on
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Hope you will help me regarding this problem
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!
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!
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.
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.
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
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
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...