|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I think the logic looks good, but would really benefit from a second set of eyes.
here is the code Code:
Option Explicit
Private Sub Form_Load()
Call ShowFileList("D:\ftp\FedEx\Invoices")
tstTimer1.Interval = 60000
End Sub
Private Sub ShowFileList(folderspec)
Dim fs, f, f1, fc
Dim FedEx1
Dim FedEx2 As String
Dim FedEx3
Dim FedExFile
Dim Counter As Long
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("D:\ftp\FedEx\Invoices")
Set fc = f.Files
On Error Resume Next
For Each f1 In fc
If fs.FileExists("D:\ftp\FedEx\invoices\fxInvDetRec.txt") Then
fs.DeleteFile ("D:\ftp\FedEx\invoices\fxInvDetRec.txt")
End If
If fs.FileExists("D:\ftp\FedEx\invoices\" & f1.Name) And f1.Name <> "D:\ftp\FedEx\invoices\fxInvDetRec.txt" Then
fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive" & f1.Name
fs.MoveFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\fxInvDetRec.txt"
Call run_FedEx_Invoice_Detail_Record_Import
FedEx1 = Shell("D:\ftp\FedEx\RECV_INVOICES.cmd")
Counter = 1
Else
FedEx1 = Shell("D:\ftp\FedEx\RECV_INVOICES.cmd")
Counter = 1
End If
Next
End Sub
Private Sub tstTimer1_Timer()
Static Counter As Long
tstTimer1.Enabled = False
Do While Counter >= 60
tstTimer1.Enabled = False
Call ShowFileList("D:\ftp\FedEx\Invoices\")
Loop
Counter = Counter + 1
End Sub
Essentially, this is what I am attempting to do. I have x number of files in the path D:\FTP\FedEx\invoices\. I want to take those files one by one and copy them to the archives and then rename them to D:\FTP\FedEx\invoices\fxInvDetRec.txt. I have to use this name as the DTS package that I am using only recognizes one named file per connection. I want this to continue until the last file that is not D:\FTP\FedEx\invoices\fxInvDetRec.txt is processed. I then want to get any new files that may be waiting for the next processing time. What do you think? |
|
#2
|
|||
|
|||
|
I have 2 problem about your code:
1.what's the "RECV_INVOICES.cmd"? If it's not a execute file,Shell call will return error! 2.U should add "\" in the statement: fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive\" & f1.Name |
|
#3
|
|||
|
|||
|
Thank you for your reply, but the .cmd file is executing correctly. It is similar to .bat file and shell isn't having a problem with it. As far as the additional '/', I really want the file to be renamed to archive & f1.name
|
|
#4
|
|||
|
|||
|
Oh,My mean is u should add "\" in the statement:fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive" & f1.Name
because this statement lack "\" after the dircetory and before the f1.name... |
|
#5
|
|||
|
|||
|
Whats the use of the static counter? in the while loop you don't change it, ...
you increase it even more so it will be always >= 60... |
|
#6
|
|||
|
|||
|
unkie, you are correct. I needed to add a reset in there and I did. I am using the timer control, so I need the static counter. I have it working now. I am still having some issues, but that isn't one of them.
|
|
#7
|
|||
|
|||
|
you could try to replce the on error move next to on error msgBox err.Description
this way the errors won't be hidden, if i'm not terribly mistaken ^^ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Can't seem to figure this out... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|