Anyone knows how to delete a file from a SFTP server using Tamir Gal's SharpSSH? I have been able to accomplish other functionality but deletion. Thanks in advance.
+2
A:
To accomplish this you will need to modify the SharpSSH assembly to expose the functionality you require.
Obtain the source code and open $\SharpSSH-1.1.1.13.src\SharpSSH\Sftp.cs
Insert the following lines of code before the end of the class:
public void Delete(string path)
{
SftpChannel.rm(path);
}
Recompile and reference the recompiled DLL in your project. You will now be able to delete files on the SFTP server.
mdsharpe
2010-04-22 12:42:12
Thank you! Stumbled upon this and it works perfectly. Just another quick tip for anyone who wants to compile this themselves, it's helpful to use the following post-build ILMerge command to end up with one handy assembly called SharpSSH.dll: `ilmerge /target:library /out:"$(TargetDir)SharpSSH.dll" /v2 "$(TargetDir)Tamir.SharpSSH.dll" "$(TargetDir)DiffieHellman.dll" "$(TargetDir)Org.Mentalis.Security.dll"`
mattmc3
2010-10-20 13:02:49
A:
Well you can also use SshExec class and then execute the "rm" command using "RunCommand" method. This way you wont have to recompile and build a new dll.
Ankur
2010-06-04 22:26:36