123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using static System.Net.WebRequestMethods;
- namespace MOTINOVA_Motor_Factory_Set
- {
- public partial class Note : Form
- {
- public string LocalPath = "/Note";
- public string FileName = "Note.txt";
- public Note()
- {
- InitializeComponent();
- }
- private void Note_Load(object sender, EventArgs e)
- {
- //检查本地文件删除
- if (System.IO.File.Exists(StartForm.UserPath + "\\" + FileName))
- System.IO.File.Delete(StartForm.UserPath + "\\" + FileName);
- //下载远程文件
- StartForm.myFtp.DownloadFile(LocalPath + "/" + FileName, StartForm.UserPath);
- //显示文件
- StreamReader objReader = new StreamReader(StartForm.UserPath + "\\" + FileName);
- string sLine = "";
- ArrayList arrText = new ArrayList();//创建一个动态数组
- while (sLine != null)
- {
- sLine = objReader.ReadLine();
- arrText.Add(sLine);
- }
- objReader.Close();
- richTextBox_Note.Clear();
- foreach (string sOutput in arrText)
- {
- richTextBox_Note.AppendText(sOutput + "\r\n");
- }
- richTextBox_Note.Text = richTextBox_Note.Text.Remove(richTextBox_Note.Text.Length - 1);
- }
- private void button_NoteRead_Click(object sender, EventArgs e)
- {
- //检查本地文件删除
- if (System.IO.File.Exists(StartForm.UserPath + "\\" + FileName))
- System.IO.File.Delete(StartForm.UserPath + "\\" + FileName);
- //下载远程文件
- StartForm.myFtp.DownloadFile(LocalPath + "/" + FileName, StartForm.UserPath);
- //显示文件
- StreamReader objReader = new StreamReader(StartForm.UserPath + "\\" + FileName);
- string sLine = "";
- ArrayList arrText = new ArrayList();//创建一个动态数组
- while (sLine != null)
- {
- sLine = objReader.ReadLine();
- arrText.Add(sLine);
- }
- objReader.Close();
- richTextBox_Note.Clear();
- foreach (string sOutput in arrText)
- {
- richTextBox_Note.AppendText(sOutput + "\r\n");
- }
- richTextBox_Note.Text = richTextBox_Note.Text.Remove(richTextBox_Note.Text.Length - 1);
- }
- private void button_NoteWrite_Click(object sender, EventArgs e)
- {
- //检查本地并删除
- if (System.IO.File.Exists(StartForm.UserPath + "\\" + FileName))
- System.IO.File.Delete(StartForm.UserPath + "\\" + FileName);
- //保存
- System.IO.File.WriteAllText(StartForm.UserPath + "\\" + FileName, richTextBox_Note.Text);
- //上传服务器
- if (!StartForm.myFtp.DirectoryExist("/", "Note"))
- StartForm.myFtp.MakeDir("/Note");
- bool result = StartForm.myFtp.UploadFile(StartForm.UserPath + "\\" + FileName, "/Note");
- if (result)
- MessageBox.Show("上传完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- else
- MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- private void Note_FormClosing(object sender, FormClosingEventArgs e)
- {
- richTextBox_Note.Clear();
- }
- }
- }
|