C# linux FTP client [客服端](2)


        /// <summary>
        /// FTP 上传
        /// </summary>
        /// <param></param>
        /// <param></param>
        private void button2_Click_1(object sender, EventArgs e)
        {
            file_name_url_image_d = "mili" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".jpg";
            FtpStatusCode status = UploadFun(textBox4.Text, "ftp://203.86.26.190/milimall/images_d/images/upload/" + file_name_url_image_d);
            FtpStatusCode status2 = UploadFun(textBox4.Text, "ftp://203.86.26.190/milimall/images/upload/Image/" + file_name_url_image_d);

if (status.ToString() == "ClosingData" && status2.ToString() == "ClosingData")
            {
                MessageBox.Show("上传成功");
                MessageBox.Show("ftp://203.86.26.190/milimall/images_d/images/upload/Image/" + file_name_url_image_d);
                mark_upload = true;
            }
            else
            {
                file_name_url_image_d = "";
                MessageBox.Show("上传失败");
            }
        }

#region FTP 上传类
        /// <summary>
        /// FTP 上传类
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <returns></returns>
        private FtpStatusCode UploadFun(string fileName, string uploadUrl)
        {
            Stream requestStream = null;
            FileStream fileStream = null;
            FtpWebResponse uploadResponse = null;
            try
            {
                FtpWebRequest uploadRequest =
                (FtpWebRequest)WebRequest.Create(uploadUrl);
                uploadRequest.Method = WebRequestMethods.Ftp.UploadFile;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wygszd.html