SFTP and LoopFiles (wodFtpDLX / wodFtpDLX.NET)
Hello
I am trying to get an example for getting a count of files in a directory along with the file names before i download using SFTP Dll.
Any help will be appreciated.
Thanks,
Premal
Hello
I am trying to get an example for getting a count of files in a directory along with the file names before i download using SFTP Dll.
Any help will be appreciated.
Thanks,
Premal
by wodDamir , (5911 days ago) @ Premal
Hi Premal,
We are talking about wodFtpDLX, right?
If so, you can check DirItems collection for Count property after ListDir is executed.
Can you try that?
Regards,
Damba
by Premal, (5911 days ago) @ wodDamir
Hello DambaI am using wodSFTP.NET. I would like to get an example of how to find out number of files exists in a folder on my SFTP server along with their fielnames and then download all of them.
Thanks,
PremalHi Premal,
We are talking about wodFtpDLX, right?
If so, you can check DirItems collection for Count property after ListDir is executed.
Can you try that?
Regards,
Damba
by wodDamir , (5911 days ago) @ Premal
Premal,
In that case, all you need to do is Call ListAttributes method on the directory, and check Args.Length parameter in AttributesData Event.
Can you try that?
Regards,
Damba
by Premal, (5910 days ago) @ wodDamir
Hello Damba
I really appreciate for the prompt feedback. Can you please provide me with an example of how to use ListAttrbutes using events in C#?
Thanks,
Premal
Premal,
In that case, all you need to do is Call ListAttributes method on the directory, and check Args.Length parameter in AttributesData Event.
Can you try that?
Regards,
Damba
by wodDamir , (5910 days ago) @ Premal
Premal,
All you need to do is this:
[code]sftp1.ListAttributes( /your/path );[/code]
And do this in AttributesData Event:
[code]void sftp1_AttributesDataEvent(object Sender, WeOnlyDo.Client.SFTP.AttributesArgs[] Args)
{
Console.WriteLine(Args.Length.ToString());
}[/code]
That's all the code you need, besides the connecting part. Can you please try that?
Regards,
Damba
by premal, (5910 days ago) @ wodDamir
Hello Damba
That works perfectly. Thanks for all your help. Also is it better to download all the files at once from a given folder on SFTP server using GetFile(string LocalPath, string RemoteFile) or should we get the names of each file and then download one by one. I guess downloading one by one may be a hit on the connectiosn to SFTP but if we downlaod all the files at once using GetFile(string LocalPath, string RemoteFile), can I verify number of files downloaded?
Thanks,
Premal
Premal,
All you need to do is this:
[code]sftp1.ListAttributes( /your/path );[/code]
And do this in AttributesData Event:
[code]void sftp1_AttributesDataEvent(object Sender, WeOnlyDo.Client.SFTP.AttributesArgs[] Args)
{
Console.WriteLine(Args.Length.ToString());
}[/code]That's all the code you need, besides the connecting part. Can you please try that?
Regards,
Damba
by wodDamir , (5910 days ago) @ premal
Premal,
It completely depends on your approach. Both ways will work. You can't know how many files were downloaded, but you can always make a member variable (i.e. FilesCount) and increase it by one on each LoopItem event.
That way you get total number of files downloaded.
Hope this helps.
Regards,
Damba
by Premal, (5910 days ago) @ wodDamir
Hello Damba
Perfect. That works great! Thanks for all your help!
Thanks,
Premal
Premal,
It completely depends on your approach. Both ways will work. You can't know how many files were downloaded, but you can always make a member variable (i.e. FilesCount) and increase it by one on each LoopItem event.
That way you get total number of files downloaded.
Hope this helps.
Regards,
Damba
by Premal, (5910 days ago) @ Premal
Hello Damba
It all works well if I use it with events. I would like to get the same functionality without using events....that is setting Blocking = true. How would i be able to get FileCount as well as FileNames for the files I want to download from SFTP server?
Thanks,
Premal
Hello Damba
Perfect. That works great! Thanks for all your help!
Thanks,
PremalPremal,
It completely depends on your approach. Both ways will work. You can't know how many files were downloaded, but you can always make a member variable (i.e. FilesCount) and increase it by one on each LoopItem event.
That way you get total number of files downloaded.
Hope this helps.
Regards,
Damba
by woddrazen , (5909 days ago) @ Premal
Premal,
You should at least use AttributesData Event to populate collection of file size. Without Events this will not work. Only if you want to parse file size from ListItem Property by yourself. ListItem Property is populated when you execute ListDir Method.
Here is example for collection:
http://www.weonlydo.com/index.asp?forum=1&action=view&topic=1087331420#1087331420
Other option is to switch to our other component wodFtpDLX.NET. wodFtpDLX.NET supports FTP, FTPS and SFTP protocol. Usage is much same as in wodSFTP.NET.
wodFtpDLX.NET supports DirItems collections which can be used outside of Events to parse directory structure. In your case file size.
[code] dlx1 = new WeOnlyDo.Client.FtpDLX();
dlx1.Hostname = hostname ;
dlx1.Protocol = WeOnlyDo.Client.Protocols.SFTP;
dlx1.Blocking = true;
dlx1.Login = login ;
dlx1.Password = password ;
dlx1.Connect();
dlx1.ListDir( /home/something );
foreach (WeOnlyDo.Client.DirItem Item in dlx1.DirItems)
{
Console.WriteLine(Item.Name + - + Item.Size);
}
Console.WriteLine(dlx1.DirItems.Count); //items count[/code]
Price diffrence between wodSFTP.NET and wodFtpDLX.NET is 20$.
Drazen
by Premal, (5909 days ago) @ woddrazen
Thanks a lot. That was great advice. I will download wodFtpDLX.NET and see how that works. Thanks again for all your help.
Thanks,
Premal
Premal,
You should at least use AttributesData Event to populate collection of file size. Without Events this will not work. Only if you want to parse file size from ListItem Property by yourself. ListItem Property is populated when you execute ListDir Method.Here is example for collection:
http://www.weonlydo.com/index.asp?forum=1&action=view&topic=1087331420#1087331420Other option is to switch to our other component wodFtpDLX.NET. wodFtpDLX.NET supports FTP, FTPS and SFTP protocol. Usage is much same as in wodSFTP.NET.
wodFtpDLX.NET supports DirItems collections which can be used outside of Events to parse directory structure. In your case file size.
[code] dlx1 = new WeOnlyDo.Client.FtpDLX();dlx1.Hostname = hostname ;
dlx1.Protocol = WeOnlyDo.Client.Protocols.SFTP;
dlx1.Blocking = true;
dlx1.Login = login ;
dlx1.Password = password ;
dlx1.Connect();dlx1.ListDir( /home/something );
foreach (WeOnlyDo.Client.DirItem Item in dlx1.DirItems)
{
Console.WriteLine(Item.Name + - + Item.Size);
}Console.WriteLine(dlx1.DirItems.Count); //items count[/code]
Price diffrence between wodSFTP.NET and wodFtpDLX.NET is 20$.
Drazen
Your support is fantastic.
It is very refreshing to find such helpful, knowledgeable and quick responding technical support.
Thank you very much for the rapid responses. I was a little nervous about dealing with a company that is on a different continent from me. You have proven my concerns to be unfounded.
Thank you for the great customer service ... I am really impressed with the wodSSH ActiveX control.
Not only wodSFTPdll is excellent, the service you have provided is outstanding and second to none!
The SFTP ocx is one of the finest pieces of programming I have seen. It worked out of the box...
The people at WeOnlyDo are amazing! ... I always get a super fast response from customer service, and the products are great too. Thanks WeOnlyDo
We are having great success with your component ... email server that has over 750 000 mailboxes back ended by a SQL server...
...with the SFTP interface you produced, everything was so simple to understand, we were able to start coding almost immediately!
Not only wodSFTPdll is excellent, the service you have provided is outstanding and second to none!