示例#1
0
 private void OnSelectLocalFiles( object sender, SelectLocalFilesEventArgs e )
 {
     using ( OpenFileDialog dialog = new OpenFileDialog()
     {
         InitialDirectory = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments ),
         CheckFileExists = true,
         Multiselect = e.SelectMultipleFiles
     } )
     {
         if ( dialog.ShowDialog( this ) == DialogResult.OK )
         {
             if ( dialog.FileNames.Length > 0 )
             {
                 e.SelectedFiles = dialog.FileNames;
             }
         }
     }
 }
示例#2
0
        private void OnSelectLocalFiles( object sender, SelectLocalFilesEventArgs e )
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                InitialDirectory = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments ),
                CheckFileExists = true,
                Multiselect = e.SelectMultipleFiles
            };

            // Unlike WindowsForms, dialogs in WPF return a nullable boolean value.
            if ( ( dialog.ShowDialog( ParentWindow ) ?? false ) && ( dialog.FileNames.Length > 0 ) )
            {
                e.SelectedFiles = dialog.FileNames;
            }
        }