예제 #1
0
 private void BTReset_Click(object sender, EventArgs e)
 {
     File.Delete(PathLine);
     RTBOriginale.ResetText();
     RTBTraduzione.ResetText();
     PBDown.Value = 0;
 }
예제 #2
0
        private void BTTradotto_Click(object sender, EventArgs e)
        {
            int check_originale  = RTBOriginale.GetLineFromCharIndex(2147483647);
            int check_traduzione = RTBTraduzione.GetLineFromCharIndex(2147483647);

            RTBTraduzione.Text += System.Environment.NewLine;
            //Read how many lines have already been translated
            System.IO.TextReader lr = new System.IO.StreamReader(PathLine);
            string linestring       = lr.ReadLine();
            int    line             = Convert.ToInt32(linestring);

            if (check_originale == check_traduzione)
            {
                RTBTraduzione.SaveFile("C:/" + Convert.ToString(line - 5) + " - " + Convert.ToString(line - 1) + ".txt", RichTextBoxStreamType.PlainText);
            }
            else
            {
                MessageBox.Show("The original text and the translated text have a different number of lines, please check the translation.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            string host     = "yourftphost";
            string user     = "******";
            string password = "******";

            Logger.CurrentLevel = Level.ALL;

            FTPClient ftp = null;

            try
            {
                // set up client
                ftp = new FTPClient(host);

                // login
                ftp.Login(user, password);

                // set up passive ASCII transfers
                ftp.ConnectMode  = FTPConnectMode.PASV;
                ftp.TransferType = FTPTransferType.ASCII;

                //Starting FTP upload
                ftp.Put("C:/" + Convert.ToString(line - 5) + " - " + Convert.ToString(line - 1) + ".txt", Convert.ToString(line - 5) + " - " + Convert.ToString(line - 1) + ".txt");

                ftp.Put(PathLine, "line.txt");

                //Delete temporary files
                lr.Close();
                ftp.Quit();

                File.Delete("C:/" + Convert.ToString(line - 5) + " - " + Convert.ToString(line - 1) + ".txt");
                BTReset_Click(sender, e);
                BTOttieni_Click(sender, e);
            }

            catch (Exception)
            {
            }
        }