This project is read-only.

Find a remaining disk space in SFTP

Mar 14, 2014 at 6:30 AM
Hi,

I'm newcomer for SFTP file transfer.Currently i have created a location as SFTP server in my local machine ( windows 7) . I have developed a project to upload file(s) from local machine to my SFTP server and working successfully. Now i'm looking how to get remaining disk space of SFTP. I have tried to find the disk space by execute a command. But i'm struck with following error

System.ArgumentException was unhandled
HResult=-2147024809
Message=Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Source=Renci.SshNet
StackTrace:
   at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.ChannelSession.SendExecRequest(String command)
   at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
   at LogFileArchive.LogFileArchive.runningcommand() in C:\Utilities\LogFileArchive\Program.cs:line 381
   at LogFileArchive.LogFileArchive.Main(String[] args) in C:\Utilities\LogFileArchive\Program.cs:line 475
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:


I was using Renci.Ssh.net dll in my project. please find the code as follows

using (SshClient sshClient = new SshClient("Host", "Port", "Username", "Password"))
{
            sshClient.Connect();
            var cmds = sshClient.RunCommand("echo 1");
            var output = cmds.Result;
}


Please anyone advise is there any other best way or how to run a command

Thanks in advance


with Regards,
Manikandan Gopal