WPF 打开一个或多个文件(可按住Ctrl键进行多选)

 private string[] GetFiles()
        {
            string[] files = null;
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.Multiselect = true;
            //dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            //dlg.FilterIndex = 2; 
            //dlg.RestoreDirectory = true;
            if (dlg.ShowDialog() == true)
                files = dlg.FileNames;
            return files;
        }

dlg.Multiselect = true;//设置是否可以多选

posted @ 2013-08-24 10:55  @妞儿  阅读(988)  评论(0编辑  收藏  举报