Click here to Skip to main content
15,921,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 vb.net that I can use to achieve this please advice.
Posted
Comments
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? :-)
--AS

1 solution

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

C#
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);
            }
            //---------------------
            uploadStream.Close();
            fileStream.Close();
            //---------------------
            requestFTPUploader = null;
}//END Upload
 
Share this answer
 

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