FormFtp.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. namespace Core.StlMes
  11. {
  12. public partial class FormFtp : FrmBase
  13. {
  14. public FormFtp()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. OpenFileDialog dialog = new OpenFileDialog();
  21. if (dialog.ShowDialog() == DialogResult.OK)
  22. {
  23. textBox3.Text = dialog.FileName;
  24. }
  25. }
  26. private void button2_Click(object sender, EventArgs e)
  27. {
  28. if (string.IsNullOrEmpty(textBox1.Text.Trim()) || string.IsNullOrEmpty(textBox2.Text.Trim()) || string.IsNullOrEmpty(textBox2.Text.Trim()))
  29. {
  30. MessageBox.Show("请输入完整上传参数!");
  31. return;
  32. }
  33. Core.Mes.Client.Comm.Server.FileBean bean = new Core.Mes.Client.Comm.Server.FileBean();
  34. bean.setFileName(textBox1.Text.Trim());
  35. bean.setPathName(textBox2.Text.Trim());
  36. bean.setFile(Core.Mes.Client.Comm.Server.FileHelper.FileToArray(textBox3.Text.Trim()));
  37. List<Core.Mes.Client.Comm.Server.FileBean> list = new List<Core.Mes.Client.Comm.Server.FileBean>();
  38. list.Add(bean);
  39. Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  40. }
  41. private void FormFtp_Load(object sender, EventArgs e)
  42. {
  43. }
  44. private void button3_Click(object sender, EventArgs e)
  45. {
  46. FolderBrowserDialog dialog = new FolderBrowserDialog();
  47. if (dialog.ShowDialog() == DialogResult.OK)
  48. {
  49. textBox4.Text = dialog.SelectedPath;
  50. }
  51. }
  52. private void button4_Click(object sender, EventArgs e)
  53. {
  54. if (string.IsNullOrEmpty(textBox4.Text.Trim()) || string.IsNullOrEmpty(textBox5.Text.Trim()))
  55. {
  56. MessageBox.Show("请输入完整上传参数!");
  57. return;
  58. }
  59. List<Core.Mes.Client.Comm.Server.FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(textBox5.Text.Trim());
  60. if (list != null && list.Count > 0)
  61. {
  62. for (int i = 0; i < list.Count; i++)
  63. {
  64. Core.Mes.Client.Comm.Server.FileBean bean = list[i];
  65. System.IO.FileStream stream = System.IO.File.Create(textBox4.Text.Trim()+"\\"+bean.getFileName());
  66. stream.Write(bean.getFile(), 0, bean.getFile().Length);
  67. stream.Close();
  68. }
  69. }
  70. }
  71. }
  72. }