0

I'm using WinSCP .NET Assembly in C# to transfer a tarball and extracting it.

My code works and I managed to copy the files. But my problem starts, when I try to extract them using session.ExecuteCommand. Nothing happens.

Trying to debug it I've added:

session.ExecuteCommand("touch /<path>/myfile.txt");

right after:

session.ExecuteCommand("tar -xzf /<path>/mytarball.tar.gz");

and the file is created, so the command and permission is not the problem and using:

result.Check();
string output = result.Output;

Shows that the files are extracted.

I'm using SCP protocol and not SFTP

Any suggesting ?

Br, Idan

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
idan357
  • 342
  • 6
  • 17

1 Answers1

1

It looks like you assume that the command will extract the files to /<path>.

It won't. It extracts them to the current working directory (what is probably /home/user).

Use -C (or --directory=) switch to specify the output directory:

session.ExecuteCommand("tar -xzf /<path>/mytarball.tar.gz -C /<path>");
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992