Wednesday, June 10, 2009

ls –lR Unix Command in sFtp C# DotNet


This code functionality facilitates the ls -lR command in C# project and is for the project which is using Tamis.SharpSsh 3rd party dll to Unix data transmission. 

ls -lR  functionality not provided by them. So I came across the need of it and wrote as below .



Download 3rd party .dll for SFTP data transmission.


 public Tamir.SharpSsh.java.util.Vector lsLr(string path)   
  {   
       Tamir.SharpSsh.java.util.Vector putLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.java.util.Vector getLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.java.util.Vector recLsEntry = new Tamir.SharpSsh.java.util.Vector();   
       Tamir.SharpSsh.jsch.ChannelSftp.LsEntry lsEntry;   
       getLsEntry = _sftp.ls(path);   
       int i = 0;   
       for (i = 0; i < getLsEntry.Count; i++)   
       {   
            lsEntry = (Tamir.SharpSsh.jsch.ChannelSftp.LsEntry)getLsEntry[i];   
            if (lsEntry.getFilename().ToString().Trim() == "." || lsEntry.getFilename().ToString().Trim() == "..") { continue; };   
            if (lsEntry.getAttrs().getPermissionsString().StartsWith("d"))   
            {   
                recLsEntry = lsLr(path + "/" + lsEntry.getFilename());   
                int j = 0;   
                 for (j = 0; j < recLsEntry.Count; j++)   
                 {   
                     putLsEntry.add(recLsEntry[j]);   
                 }   
            }   
            else   
            {   
                putLsEntry.add(lsEntry);   
            }   
       }   
       return putLsEntry;   
 }   

No comments:

Post a Comment

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code