🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Hanifi NARMOT / C# / FTP Kaydetme

1-) C# - FTP Kaydetme

 

 

 public void ftpEvrakKaydet(string gelenPath,string evrakYol)

        {

 

            try

            {

                openFileDialog1.Title = "Dosya Seçiniz";

                openFileDialog1.FileName = "Dosya Seçiniz";

                    

                openFileDialog1.ShowDialog();

 

                FileInfo filei = new FileInfo(gelenPath);

                 string adres = "ftp://ftpyolunugir/"+evrakYol+"/";

                string path = adres + filei.Name;

                FtpWebRequest FTP;

                FTP = (FtpWebRequest)FtpWebRequest.Create(path);

                FTP.KeepAlive = false;

                FTP.Method = WebRequestMethods.Ftp.UploadFile;

                FTP.UseBinary = true;

                FTP.ContentLength = filei.Length;

                int buffLength = 1024;

                byte[] buff = new byte[buffLength];

                int contentLen;

                FileStream FS = filei.OpenRead();

                try

                {

                    Stream strm = FTP.GetRequestStream(); contentLen = FS.Read(buff, 0, buffLength); while (contentLen != 0)

                    {

                        strm.Write(buff, 0, contentLen); contentLen = FS.Read(buff, 0, buffLength);

                    }

                    strm.Close();

                    FS.Close();

                    txtSaglikRapor.Text = path;

 

 

                }

                catch

                {

                }

            }

            catch (Exception)

            {

                MessageBox.Show("Yükleme yapılamadı");

            }

        }

 2021 Şubat 28 Pazar
 346