Tuesday, May 13, 2008

Using SFTP in VB.net

In my last blog, I talked about using ftp in vb.net. This time I will introduce a way to use SFTP in VB.net.

Same as call Windows ftp.exe in VB.net, you can call an SFTP client. Since Windows dosen't include any default SFTP client software, you need to find and install one. I used an open source free SFTP client called WinSCP, which supports scripting.

WinSCP has an very cool command-"synchronize". It can synchronize remote directory with your local.

The following is an example scripting txt file:
open username:password@hostname
synchronize remote [local directory] [remote directory]
chmod 777 [remote directory]\*.*
close
exit

After having created the scripting file, include the following line in a batch file and let VB.net to call the batch file:
winscp.exe /console /script=example.txt

1 comment:

Sridhar Gudipati said...

Nice article. Thanks!