Solved

HOW TO IMPLEMENT SFTP using c#

Posted on 2013-01-09
4
389 Views
Last Modified: 2013-01-11
I have the following task to implement  in a existing console application.

Can you enlighten me?

The task:

When the process is run it accepts an argument “-mailer” this will trigger the
processMailer() function. The file that is generated
in that function needs to be transferred via SFTP to
the following server info:
 
Server:                 xx.122.xxx.xxx
UID:                       azaz_group
PWD:                     xxxxxxx
 
I expect that these server details will be stored in the app.config
file so that they can be configured in the future.

How would I code this and setup in the existing app_code
I need to do this asap as the user has given me little time to implement.

Thanks,
Isaac
0
Comment
Question by:TechIsaac
  • 3
4 Comments
 
LVL 14

Accepted Solution

by:
binaryevo earned 500 total points
ID: 38760292
0
 

Author Comment

by:TechIsaac
ID: 38763284
I found SharpSSH which works nicely.

I would like to use my app_code values instead of hard code.

Is there a way to do this without a lot of string manipulation?

I am now getting the values in myString but I am using hard code.

//new code here
                string myString = ConfigurationManager.AppSettings["SftpConnectionString".ToString()];
                Sftp scp = new Sftp("00.000.000.000", "dndn_xxxxxxx");
                scp.Password = "xxxxxxxx";
                scp.Connect(00);
                scp.Put(xFerFile,xFerFile);
                scp.Close();
                tw.WriteLine(string.Format("{0:yyyy/MM/dd_hh:mm:ss:tt}", DateTime.Now) + " process completed successfully");
                tw.WriteLine(string.Format("{0:yyyy/MM/dd_hh:mm:ss:tt}", DateTime.Now) + " server transfer completed successfully");
                tw.Close();
0
 

Author Comment

by:TechIsaac
ID: 38764114
I found a solution:

string sremote = ConfigurationManager.AppSettings["SftpConnectionString".ToString()];
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(sremote);
                string user = builder.UserID;
                string pass = builder.Password;
                string server = builder.DataSource;

Isaac
0
 

Author Comment

by:TechIsaac
ID: 38767802
I've requested that this question be closed as follows:

Accepted answer: 0 points for TechIsaac's comment #a38764114

for the following reason:

The solution works in my application<br /><br />Isaac
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know for anybody starting from Beginner to Expert in Networking knows what OSI model. But this tutorial is for freshers or those who are new to networking world. Why I am putting OSI in such simple and compact manner is because it enables you to k…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now