netdragon-cai


        public void SyncToDownloadServer(string server, string filePath, string fileName)
        {
            var username = "ccccaa1";
            var password = "test";

            string ftpfullpath = "ftp://" + server + "/" + fileName;
            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
            ftp.Credentials = new NetworkCredential(username, password);
            //userid and password for the ftp server to given  

            ftp.KeepAlive = true;
            ftp.UseBinary = true;
            ftp.UsePassive = false;

            ftp.Method = WebRequestMethods.Ftp.UploadFile;
            FileStream fs = File.OpenRead(filePath);
            byte[] buffer = new byte[fs.Length];
            fs.Read(buffer, 0, buffer.Length);

            fs.Close();
            Stream ftpstream = ftp.GetRequestStream();
            ftpstream.Write(buffer, 0, buffer.Length);
            ftpstream.Close();


        }

分类:

技术点:

相关文章:

  • 2021-12-12
  • 2021-12-12
  • 2021-11-17
  • 2021-11-17
  • 2021-11-07
  • 2021-11-17
猜你喜欢
  • 2021-11-17
  • 2021-11-17
  • 2021-11-17
  • 2022-02-09
  • 2021-07-17
  • 2021-09-10
  • 2021-11-17
相关资源
相似解决方案