Current filter:
                                You should refresh the page.
                                  • Hello DX,

                                    When using the CustomizeOpenFileDialogFileNames event, the args.FileNames contains duplicate file names because the list of filenames selected is added twice in the AddFromFile method. From "...\Sources\DevExpress.ExpressApp.Modules\DevExpress.ExpressApp.FileAttachment.Win\FileAttachmentListViewController.cs":

                                    [C#]
                                    protected virtual void AddFromFile() { using(OpenFileDialog dialog = new OpenFileDialog()) { dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.DereferenceLinks = true; dialog.Multiselect = true; dialog.Filter = GetFileTypesFilter(); if(dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { CustomizeOpenFileDialogFileNamesEventArgs args = new CustomizeOpenFileDialogFileNamesEventArgs(dialog.FileNames, dialog); //<------ FIRST TIME args.FileNames.AddRange(dialog.FileNames); //<------ SECOND TIME OnCustomizeOpenFileDialogFileNames(args); AddFiles(args.FileNames.ToArray()); } } }

                                    So a selection of 2 files would result in a list with 4 items:

                                    [CSS]
                                    "C:\Example\1.txt" "C:\Example\2.txt" "C:\Example\1.txt" "C:\Example\2.txt"

                                    Thanks for looking into this.

                                    Alex

                                • Andrey K (DevExpress Support) 11.08.2018

                                  Hello,

                                  Thank you for your report. We will investigate this issue.
                                  Let me post your workaround for other users:

                                  [C#]
                                  using DevExpress.ExpressApp; using DevExpress.ExpressApp.FileAttachments.Win; namespace dxT689164.Module.Win.Controllers { public class CustomWinController : ViewController { protected override void OnActivated() { base.OnActivated(); fileController = Frame.GetController<FileAttachmentListViewController>(); if(fileController != null) fileController.CustomizeOpenFileDialogFileNames += CustomWinController_CustomizeOpenFileDialogFileNames; } FileAttachmentListViewController fileController; private void CustomWinController_CustomizeOpenFileDialogFileNames(object sender, CustomizeOpenFileDialogFileNamesEventArgs e) { if(e.FileNames.Count > 0 && e.FileNames.Count % 2 == 0) { int halfCount = e.FileNames.Count / 2; e.FileNames.RemoveRange(halfCount, halfCount); } } protected override void OnDeactivated() { base.OnDeactivated(); if(fileController != null) fileController.CustomizeOpenFileDialogFileNames -= CustomWinController_CustomizeOpenFileDialogFileNames; } } }

                                  Thanks,
                                  Andrey

                                1 Solution

                                Creation Date Importance Sort by
                                • Alex Miller 11.13.2018

                                  All ok in build 18.2.3.18317 . Thanks for the quick fix.

                                • Joseph Kellerer 11.13.2018

                                  Dito

                                • Andrey K (DevExpress Support) 11.13.2018

                                  You are welcome!