This project is read-only.
1

Closed

Member function DownloadFile in MainPage.cs with null value ddialog variable

description

There is a variable [ddialog] with null value that is called before an instance is created in DowloadFile member function in MainPage.cs [line 324] in TestClient project. See below.
 
if (saveFileDialog.ShowDialog() == true)
    {
      string hexColorString = ((ComboBoxItem)this.cboBackgroundDownload.SelectedItem).Tag.ToString();
      string metadata = file.FileName;
      ddialog.DownloadUri = "";  --->> must be commented  <<----
      ddialog = new DownloadFileDialog(saveFileDialog.SafeFileName, saveFileDialog.OpenFile(), false, metadata);
      ddialog.Title = this.txtTitleDownload.Text;
Closed Aug 20, 2010 at 1:07 PM by hyspdrt

comments

hyspdrt wrote Aug 20, 2010 at 12:55 PM

The variable ddialog is defined just prior to {{if (saveFileDialog.ShowDialog() == true)}}

Here's the full source...

{{
void DownloadFile()
    {
        if (null == this.dtgFiles.SelectedItem)
            return;

        TestClient.Web.InterlinkFile file = this.dtgFiles.SelectedItem as TestClient.Web.InterlinkFile;
        if (null == file)
            return;
        string ext = Path.GetExtension(file.FileName);

        SaveFileDialog saveFileDialog = new SaveFileDialog();
        try
        {
            saveFileDialog.Filter = "All files (*.*)|*.*|File (*" + ext + ")|*" + ext;
            saveFileDialog.FilterIndex = 2;
            DownloadFileDialog ddialog = null;
            if (saveFileDialog.ShowDialog() == true)
            {
                string hexColorString = ((ComboBoxItem)this.cboBackgroundDownload.SelectedItem).Tag.ToString();
                string metadata = file.FileName;
                ddialog.DownloadUri = "";
                ddialog = new DownloadFileDialog(saveFileDialog.SafeFileName, saveFileDialog.OpenFile(), false, metadata);
                ddialog.Title = this.txtTitleDownload.Text;
                ddialog.IsTitleImageVisible = this.chkShowTitleImageDownload.IsChecked.Value;
                ddialog.Background = new System.Windows.Media.SolidColorBrush(Color.FromArgb(
                                                                                    Convert.ToByte(hexColorString.Substring(1, 2), 16),
                                                                                    Convert.ToByte(hexColorString.Substring(3, 2), 16),
                                                                                    Convert.ToByte(hexColorString.Substring(5, 2), 16),
                                                                                    Convert.ToByte(hexColorString.Substring(7, 2), 16)));
                if (null != ddialog)
                {
                    ddialog.Show();
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            Debug.WriteLine(ex.ToString());
        }
    }
}}
'

hyspdrt wrote Aug 20, 2010 at 12:58 PM

Ignore last comment. Misread your first comment. Good catch and thanks!!

wrote Aug 20, 2010 at 12:59 PM

wrote Aug 20, 2010 at 1:07 PM

Removed the line in question.

wrote Feb 14, 2013 at 7:39 PM

wrote May 16, 2013 at 9:40 AM

wrote Dec 1 at 2:16 AM