Loopfiles and delete - WeOnlyDo Discussion board

Loopfiles and delete (wodSFTP / wodSFTP.NET / wodSFTPdll)

by havey, Thursday, October 12, 2006, 00:16 (6427 days ago)

Hi, i using asp to getFiles from a remote server to local, that works great!

I'm having issues with LoopFiles and deleteFile from LoopFiles names.

My situation is that the remote server can place a files in the sftp folder at any time, I don't want to delete a file that might have been placed while i finished the GETFiles method and onto the deleteFiles method, so i was thinking that if i can get the file names of the GetFiles and delete them based on their names then i would have not conflicts. Hopefully i'm going about this the correct way:

Sftp.GetFiles E:wwwrootwww est , /ftp/www/rk/ON/

Sftp.LoopFiles /ftp/www/rk/ON/

for each name in LoopFiles
Sftp.DeleteFile /ftp/www/rk/ON/ & name
next

Sftp.Disconnect


Thanks![:wink:]

Re: Loopfiles and delete

by wodSupport, Thursday, October 12, 2006, 01:10 (6427 days ago) @ havey

Havey,

I would suggest you check out this post:

http://www.weonlydo.com/index.asp?forum=1&action=view&topic=1087331420

idea is to put all file names into one collection, and then delete one file at a time - more/less what you need. It would be better if you could get events for that, but since you're in ASP I don't see how to accomplish it. Perhaps if you could make COM object called from ASP?

But that's the general idea, use LoopFiles to construct collection of file names, and then delete files from the collection manually, as long as there are elements in the collection.

Kreso

Re: Loopfiles and delete

by havey, Thursday, October 12, 2006, 20:56 (6426 days ago) @ wodSupport

Havey,

I would suggest you check out this post:

http://www.weonlydo.com/index.asp?forum=1&action=view&topic=1087331420

idea is to put all file names into one collection, and then delete one file at a time - more/less what you need. It would be better if you could get events for that, but since you're in ASP I don't see how to accomplish it. Perhaps if you could make COM object called from ASP?

But that's the general idea, use LoopFiles to construct collection of file names, and then delete files from the collection manually, as long as there are elements in the collection.

Kreso

Re: Loopfiles and delete

by havey, Thursday, October 12, 2006, 22:00 (6426 days ago) @ havey

sorry, having posting issues..

How can i iterate thru listNames ? below is what i'm trying to do

Sftp.ListNames /ftp/www/rk/ON/

For each x in Sftp.ListNames
response.write Sftp.ListNames(x) & vbCRLF
Next

Re: Loopfiles and delete

by wodSupport, Thursday, October 12, 2006, 22:21 (6426 days ago) @ havey

If you use blocking mode then it's more/less the same, just do

Ftp1.ListDir ( /...... ) (not listnames, ListDir...)
for each d in Ftp1.DirItems
Debug.Print d.name
next

can you try that?

Re: Loopfiles and delete

by havey, Thursday, October 12, 2006, 22:44 (6426 days ago) @ wodSupport

this is what i tried without success:

Sftp.Connect

Sftp.ListDir ( /ftp/ftpdelivery/lodging/dbqa/rk/ON/ )
for each d in Sftp.DirItems
response.write(d.name)
next

error:
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'DirItems'

Re: Loopfiles and delete

by wodSupport, Thursday, October 12, 2006, 22:59 (6426 days ago) @ havey

What product do you use wodFtpDLX or wodSFTP? If it's wodSFTP, aren't we in wrong thread?

If it's wodSFTP, then you don't have DirItems, you would have to use events as explained in thread I pointed to.

Can you have events?

Kreso

Re: Loopfiles and delete

by havey, Friday, October 13, 2006, 01:19 (6426 days ago) @ wodSupport

changing threads