• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Autosend a file in a directory.

I would like to autosend a file that is created in a directory (A) to another directory (B) in every 1 minute.

I already have a send file program for visual basic. Can someone help me add the above function into my program below.

In the first buttons click event:
   With Me.CommonDialog1
       .DialogTitle = "Choose File:"
       .InitDir = App.Path
       .ShowOpen
   End With
   
   If Me.CommonDialog1.FileName <> "" Then
       Me.List1.AddItem Me.CommonDialog1.FileName
   End If

In the second buttons click event:

In the second buttons click event:
'there is a better way to do this with the API, but
'this is easier.

   With Me.CommonDialog1
       .DialogTitle = "Choose Send To Path:"
       .InitDir = App.Path
       .FileName = "x"
       .ShowOpen
   End With
   
   If Me.CommonDialog1.FileName <> "" Then
       Me.Label1.Caption = Mid(Me.CommonDialog1.FileName, 1, InStrRev(Me.CommonDialog1.FileName, "\"))
   End If

In the third buttons click event do either:
Dim iItem as integer
Dim strFile as string

For iItem = Me.List1.ListCount - 1 To 0 Step -1
    strFile = Dir(Me.List1.List(iItem))
    FileCopy Me.List1.List(iItem), Me.Label1.Caption & strFile
    Kill Me.List1.List(iItem)
    Me.List1.RemoveItem (iItem)
Next iItem
0
elyn_09
Asked:
elyn_09
1 Solution
 
DocMCommented:
Hi,
The first button and the second button are OK.

Add a Timer control to your form.

Private Sub Timer1_Timer()

 Dim iItem as integer
 Dim strFile as string

 For iItem = Me.List1.ListCount - 1 To 0 Step -1
   strFile = Dir(Me.List1.List(iItem))
   FileCopy Me.List1.List(iItem), Me.Label1.Caption &  strFile
   Kill Me.List1.List(iItem)
   Me.List1.RemoveItem (iItem)
 Next iItem

End Sub

In the third buttons click event do either:

 Timer1.Interval = 60000
 Timer1.Enabled = True
0
 
elyn_09Author Commented:
I tried. Its not the program i wanted. I wanted a program that can autosend the file ( maybe lets say a file named ABC.txt ) created in directory A to directory B. Thats all.
0
 
DocMCommented:
OK then. Try this code. Put 2 Label controls, 2 Command controls and one Timer control.

Private Sub Command1_Click()
    Label1.Caption = ""
    With CommonDialog1
        .DialogTitle = "Choose File:"
        .InitDir = App.Path
        .ShowOpen
    End With
    If CommonDialog1.FileName <> "" Then
        Label1.Caption = CommonDialog1.FileName
    End If
End Sub

Private Sub Command2_Click()
    With Me.CommonDialog1
        .DialogTitle = "Choose Send To Path:"
        .InitDir = App.Path
        .FileName = "x"
        .ShowOpen
    End With
    If Me.CommonDialog1.FileName <> "" Then
        Me.Label2.Caption = Mid(Me.CommonDialog1.FileName, 1, InStrRev(Me.CommonDialog1.FileName, "\"))
    End If
End Sub

Private Sub Form_Load()
    Timer1.Interval = 60000
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    On Error GoTo ErrorHandling
    If Dir(Label1.Caption) <> "" Then
        If Label2.Caption <> "" Then
            FileName = Mid(Label1.Caption, InStrRev(Label1.Caption, "\") + 1)
            Path = Label2.Caption
            If Right(Path, 1) <> "\" Then Path = Path & "\"
            FileCopy Label1.Caption, Path & FileName
            Kill Label1.Caption
        End If
    End If
    Exit Sub
ErrorHandling:
    MsgBox "Error :" & Err.Number & " - " & Err.Description
End Sub
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
CleanupPingCommented:
Hi elyn_09,
This old question (QID 20556839) 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:
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I would appreciate any comments by the experts that would help me in making a recommendation.
It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

GPrentice00
Cleanup Volunteer
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 DocM's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now