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