How to get filesystem size

May 25, 2012 at 7:49 AM

Hello,

Is it possible to get file system size (Total space, available space and used space)?

Vijay

May 28, 2012 at 7:10 PM

I use this but it's for older version of library. Hope it helps.

 

using (var cmd = new SshCommand(Session, String.Format(" df -Pk {0}", _rootpath), Encoding.ASCII))
                        // POSIX standard df
                    {
                        cmd.Execute();
                        if (cmd.ExitStatus == 0)
                        {
                            var values = cmd.Result.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
                            long  total = Int64.Parse(values[values.Length - 5]) << 10;
                            long  used = Int64.Parse(values[values.Length - 4]) << 10;
                            long   free = Int64.Parse(values[values.Length - 3]) << 10; // in bytes 
                        }
}
May 29, 2012 at 5:58 AM
Edited May 29, 2012 at 6:21 AM

Yes i have tried this, but the only difference is that "df -pk" command is not working on my router. and i have used object of "SshClient" instead of SshCommand.

So i have used "df -k | grep <root>" and it is working fine...

above command will give response in kb.

Thanks for reply.


Coordinator
Jun 5, 2012 at 9:01 PM

Hi,

 

Did you try SftpFile.Length property?

I populate it with file size that being returned by the system.

 

Thanks,

Oleg