Solved

HOW TO IMPLEMENT SFTP using c#

Posted on 2013-01-09
4
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

705 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