示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            switch (btnOK.Tag.ToString())
            {
            case "OK":

                fileTransfer.DataStream = new FileStream(txtFilePath.Text, FileMode.Create, FileAccess.Write);
                fileTransfer.Accept();

                btnCancel.Visible = false;

                lblSize.Text = "Waiting to start...";

                btnOK.Text = "Abort Transfer";
                btnOK.Tag  = "ABORT";
                break;

            case "ABORT":

                fileTransfer.Abort();

                btnOK.Text = "Close";
                btnOK.Tag  = "CLOSE";
                break;

            case "OPENFILE":
                Process.Start(txtFilePath.Text);
                Close();
                break;

            case "CLOSE":
                Close();
                break;
            }
        }