NetTalk FTP > FTP - Ask For Help
Get Directory and Delete Files
rupertvz:
Hi Guys,
I am following the NetTalk example to download a directory (all files) from an FTP server.
It is working well ...
How do I delete the files as being downloaded? To make sure we don't download duplicate files ...
Bruce:
use the DeleteFile(RemoteFileName) command;
http://www.capesoft.com/docs/NetTalk10/NetTalkFTP.Htm#Commands
Cheers
Bruce
rupertvz:
Thanks Bruce,
I just need to confirm that the file was successfully downloaded, before deleting the remote-file.
Looking at the "GetNextFile" routine in the example app:
I've added the line below? (is this the correct place for adding the line)
GetNextFile Routine
data
found long
code
loop until records (ThisFTPControl.DirListingQ) = 0
QueueProgress += 1
get (ThisFTPControl.DirListingQ ,1)
If ThisFTPControl.DirListingQ.Attrib <> 0
conversation = '-- Ignoring Not-A-file : ' & clip(ThisFTPControl.DirListingQ.Name) & '<13,10>' & Conversation
delete (ThisFTPControl.DirListingQ)
cycle
end
conversation = '-- Fetching file : ' & clip(ThisFTPControl.DirListingQ.Name) & '<13,10>' & Conversation
ThisFTPControl.GetRemoteFile(clip (ThisFTPControl.DirListingQ.Name),clip(pParms.pLocalFileName) & '\' & ThisFTPControl.DirListingQ.Name)
?status{prop:text} = clip(pParms.pLocalFileName) & '\' & ThisFTPControl.DirListingQ.Name
ThisFTPControl.DeleteFile(ThisFTPControl.DirListingQ.Name)
delete (ThisFTPControl.DirListingQ)
found = 1
break
end
Bruce:
The GetRemoteFile command is asynchronous.
So the call there will _start_ it downloading.
Clearly you're not waiting for the result of the download, and not checking to see the file was "complete" (whatever that means), before scheduling the DeleteFile command. So the file will then be deleted regardless of the success of fail of the GetRemoteFile command.
I'd recommend inspecting the example to see where a file has been completely received, and then doing your tests, and call to DeleteFile there.
cheers
Bruce
rupertvz:
Hi Bruce,
I am deleting the remote file as follows:
ThisFTPControl.DeleteFile(ThisFTPControl.DirListingQ.Name)
This is working, but next time I run the "GetDirectoryOverFtp" procedure, it picks up the same file name.
Which implies that the file was not initially deleted.
However, trying to the delete the file again, gives me:
"File Access Error.File Unavailable"
"No such File or Directory"
"The error number was -41 / 550 which means a general FTP error occured"
If the file was indeed deleted the first time round, why in a new thread does it pickup the same filename from the queue
"ThisFTPControl.DirListingQ.Name" ?
Navigation
[0] Message Index
[#] Next page
Go to full version