Click here to Skip to main content
15,844,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get documents from local machine to server machine automatically sync thorugh SFTP using C# programming

My Windows machine connect Sever machine via SFTP is perfect but i manually upload document to server and download documents from server.
My requirement is its all documents are sync automatically in console application doing via program using c#

Please Help me

Thanks in advance

What I have tried:

I tried Manually upload and download document but i need its all automatic through coding
Posted
Updated 9-Apr-18 23:49pm
Comments
OriginalGriff 10-Apr-18 3:53am    
What have you tried?
Where are you stuck?
What help do you need?
Alriyan 10-Apr-18 4:45am    
I Have code or need example of automatic sync from local machine to server.
https://www.youtube.com/watch?v=0lOOuGJOg1o i tired this link but its manual i need automatic

1 solution

There is no need to write your own application which is a quite complex task.

You can use the WinSCP :: Official Site :: Free SFTP and FTP client for Windows[^] instead.

It provides Scripting and Task Automation :: WinSCP[^] which can be called periodically from a scheduler with a script to synchronise specified directories (see keepuptodate :: WinSCP[^]).

Have a look at the WinSCP documentation even if you still want to write your own application. It contains useful information on how to implement features with .Net like those on the keepuptodate option:
Quote:
Converting to .NET Assembly

There is no equivalent for keepuptodate command in .NET assembly.

You can make use of System.IO.FileSystemWatcher to run non-recursive synchronization using Session.SynchronizeDirectories, when change in local directory occurs.
 
Share this answer
 
Comments
Alriyan 10-Apr-18 7:33am    
Please suggest complete solution or example project. I tried winscp is not working me properly
Jochen Arndt 10-Apr-18 8:04am    
You have to read the documentation and the examples. Use the interactive command line mode first to learn the syntax and find out which commands has to be used for your task. Finally write the commands to a script file and execute that with
winscp.exe /console /script="myscript.txt" /log="myscript.log"

Untested example myscript.txt:
open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 ..."
lcd <local directory>
cd <remote directory>
# Reflect changings in local dir to remote dir,
# remote to local, or in both directions
synchronize {local|remote|both]
# Repeat for other directories if necessary
close
exit

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900