码迷,mamicode.com
首页 > Windows程序 > 详细

WPF中弹出文件夹浏览对话框

时间:2016-09-05 18:56:37      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:

附一个共享目录正则表达式判断:

bool result= System.Text.RegularExpressions.Regex.IsMatch("\\pc-test\share", @"^\\\\[a-zA-Z0-9\.-]+(\\([^\\\?\/\*\|<>:" + "\"" + "])+){1,}$");

 

        private void btnSelectNetShareDir_Click(object sender, RoutedEventArgs e)
        {
            txtNetUploadDir.Text = string.Empty;

            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            System.Windows.Interop.HwndSource hwn = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
            System.Windows.Forms.IWin32Window win = new WinFormWindow(hwn.Handle);
            fbd.ShowNewFolderButton = true;
            fbd.Description = "请选择共享目录...";
            if (fbd.ShowDialog(win) == System.Windows.Forms.DialogResult.OK)
            {
                txtNetUploadDir.Text = fbd.SelectedPath;
            }
        }
        public class WinFormWindow : System.Windows.Forms.IWin32Window
        {
            IntPtr _handle;
            public WinFormWindow(IntPtr handle)
            {
                _handle = handle;
            }
            IntPtr System.Windows.Forms.IWin32Window.Handle
            {
                get { return _handle; }
            }
        }

 

WPF中弹出文件夹浏览对话框

标签:

原文地址:http://www.cnblogs.com/wjshan0808/p/5842941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!