Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# VB.NET
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 19-Sep-12 14:10pm
Comments
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
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);
            }
            //---------------------
            uploadStream.Close();
            fileStream.Close();
            //---------------------
            requestFTPUploader = null;
}//END Upload
  Permalink  

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

  Print Answers RSS
0 Maciej Los 404
1 OriginalGriff 379
2 CPallini 145
3 Sergey Alexandrovich Kryukov 142
4 Hard_Rockz 115
0 OriginalGriff 5,634
1 Sergey Alexandrovich Kryukov 4,763
2 Peter Leow 2,954
3 Maciej Los 2,614
4 DamithSL 2,465


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