Click here to Skip to main content
13,000,742 members (56,781 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need help with connection two remote severs over the internet to share files and sync them. The system is supposed to balance the file on both servers at least fast. Please if you know any sample c# or that I can use to achieve this please advice.
Posted 19-Sep-12 14:10pm
Sergey Alexandrovich Kryukov 19-Sep-12 20:29pm
Interesting question, but a number of points are hard to understand. What is "remote FTP"? What, is some kind of "local FTP" already invented? What is "balance the file"? Especially at "least fast". What is at most? Infinite speed? :-)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The code below is how to upload a file using ssl. EnableSSL = true; is this what you were looking for?

private NetworkCredential FtpLogin()
    return new NetworkCredential(FtpUser, FtpPass);
public void Put(string filename)
            FtpWebRequest requestFTPUploader = (FtpWebRequest)WebRequest.Create(string.Format(@"{0}/{1}", FtpServer, Path.GetFileName(filename)));
            requestFTPUploader.Credentials = FtpLogin();
            requestFTPUploader.Method = WebRequestMethods.Ftp.UploadFile;
            requestFTPUploader.EnableSsl = true;
            FileInfo fileInfo = new FileInfo(filename);
            FileStream fileStream = fileInfo.OpenRead();
            int bufferLength = 2048;
            byte[] buffer = new byte[bufferLength];
            Stream uploadStream = requestFTPUploader.GetRequestStream();
            int contentLength = fileStream.Read(buffer, 0, bufferLength);
            while (contentLength != 0)
                uploadStream.Write(buffer, 0, contentLength);
                contentLength = fileStream.Read(buffer, 0, bufferLength);
            requestFTPUploader = null;
}//END Upload

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100