shrikant kesharwani
How can we use SFTP in C# to transfer file to another location ?
Posted by shrikant kesharwani in .Net | ASP.NET on Oct 18, 2011
0
Do you know the answer for this question? Post it below.
Guest

Steps to transfer file from one loc to other

1)Mention the path,user credentials like
string s  += "192.168.0.61" + " ";
        s += "-l " + "XYZ" + " ";
        s += "-pw " + "XYZ" + " ";
where
- l-login
-pw-password
System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo();
        startinfo.CreateNoWindow = false;
        startinfo.UseShellExecute = false;
        startinfo.FileName = Server.MapPath("~/Pres/psftp.exe");

        startinfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        startinfo.Arguments = textfile;
        startinfo.RedirectStandardInput = true;
        startinfo.RedirectStandardOutput = true;
        Process p = Process.Start(startinfo);
        p.StandardInput.WriteLine("cd foldername");
        FileInfo[] files = new DirectoryInfo(Server.MapPath("~//Bach/")).GetFiles("*.txt", SearchOption.TopDirectoryOnly);
        foreach (FileInfo tfile in files)
        {

            fileFullName = tfile.FullName;
            filename = Path.GetFileNameWithoutExtension(tfile.Name);
            list.Add(filename);
            p.StandardInput.WriteLine("mput " + fileFullName);
        }
        p.StandardInput.WriteLine("quit");

Posted by shravan kumar on Nov 02, 2011
Sponsored by

Become a Sponsor
PREMIUM SPONSORS
Sponsored by
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | REPORT ABUSE © 2011 C# Corner. All contents are copyright of their authors.