Ho fatto un piccolo programma che mi consente di inviare file in automaticamente con pcanywhere.
Per la copia del file inesistente all'interno della directory il procedimento va a buon fine.
Quando invece vado a sovrascrivere un file gia esistente il procedimento non va a buon fine.
Da cosa puo dipendere?
Dove ho sbagliato?
Esempio del programma:
Dim NomedelFile As String
Dim NomeFil As String
Dim FileChf As String
Dim Destinazione As String
Dim Errori As Integer
Private Sub Avvio_Click()
Dim oTestApp, strSource, strDestination, strCommand
On Error GoTo Errore
If Dir(FileChf & "*.chf", vbDirectory) <> "" Then
NomeFil = Dir(FileChf & "*.chf", vbDirectory)
Do While NomeFil <> ""
Set oTestApp = CreateObject("AWREM32.APPLICATION")
oTestApp.awConnect (FileChf & NomeFil)
'Transfer From Host
strSource = NomedelFile
strDestination = Destinazione
bResult = oTestApp.FileXferFromHost(strSource, strDestination)
'Transfer to Host
strSource = NomedelFile
strDestination = Destinazione
bResult = oTestApp.FileXferToHost(strDestination, strSource)
If bResult = True Then
List1.AddItem NomeFil
ElseIf bResult = False Then
List2.AddItem NomeFil
End If
'Execute Program on remote computer
'strCommand = "C:\winnt\notepad.exe"
bResult = oTestApp.ExecuteHostFile(strCommand)
NomeFil = Dir
If Errori = 1 Then
Errore:
List2.AddItem NomeFil
NomeFil = Dir
Errori = 0
End If
Loop
End If
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
If Dir(App.Path & "\InvioFile.ini", vbArchive) <> "" Then
' Apertura file ini
fd_ini = FreeFile
Open App.Path & "\InvioFile.ini" For Input As fd_ini
' Scorro file ini
While EOF(fd_ini) = False
Line Input #fd_ini, rigo
' Verifico se c'è un "=" nel rigo
cerca = InStr(1, rigo, "=")
If cerca <> 0 Then
letto = Left(rigo, cerca - 1)
' Carico variabili file ini
Select Case letto
Case "FileChf"
FileChf = Mid(rigo, cerca + 1)
Case "Nomefile"
NomedelFile = Mid(rigo, cerca + 1)
Case "Destinazione"
Destinazione = Mid(rigo, cerca + 1)
End Select
End If
Wend
End If
End Sub