private void sendAFileToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = string.Format("{0} (*.*)|*.*", Resources.Dialog_AllFiles); if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { try { using (ExtendedFileStream fs = new ExtendedFileStream(ofd.FileName)) { using (FileSendProgressForm form = new FileSendProgressForm(new FileInfo(ofd.FileName).Name, fs, rdpClient)) { form.ShowDialog(this); } } } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("Cannot open file '{0}'", ofd.FileName), ex); } MessageBox.Show(this, string.Format(Resources.Error_CannotOpenFile, ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// Initializes a new instance of the <see cref="FileSendProgressForm" /> class. /// </summary> /// <param name="fileNameWithoutPath">The file name without path.</param> /// <param name="stream">The stream.</param> /// <param name="service">The service.</param> public FileSendProgressForm(string fileNameWithoutPath, ExtendedFileStream stream, RemoteDesktopWinFormsControl service) : this() { if (string.IsNullOrEmpty(fileNameWithoutPath)) { ThrowHelper.ThrowArgumentNullException("fileNameWithoutPath"); } if (stream == null) { ThrowHelper.ThrowArgumentNullException("stream"); } if (service == null) { ThrowHelper.ThrowArgumentNullException("service"); } mFileName = fileNameWithoutPath; mStream = stream; mService = service; lTotalSizeValue.Text = mStream.Length.ToString(mNumberPattern); lSentBytesValue.Text = mStream.Position.ToString(mNumberPattern); lPercentValue.Text = Convert.ToInt32(mStream.Position / (mStream.Length / 100)).ToString(mNumberPattern); }