Attach a shared directory regular expression to judge:
bool result= System.Text.RegularExpressions.Regex.IsMatch ("\\pc-test\share" @" ^\\\\[a-za-z0-9\.-]+ (\ \ [^\\\?\/\*\|<>:"\" "" ]) +) {1,}$");
Private voidBtnselectnetsharedir_click (Objectsender, RoutedEventArgs e) {Txtnetuploaddir.text=string. Empty; System.Windows.Forms.FolderBrowserDialog FBD=NewSystem.Windows.Forms.FolderBrowserDialog (); System.Windows.Interop.HwndSource hwn= Presentationsource.fromvisual ( This) asSystem.Windows.Interop.HwndSource; System.Windows.Forms.IWin32Window win=NewWinformwindow (hwn. Handle); Fbd. Shownewfolderbutton=true; Fbd. Description="Please select a shared directory ..."; if(FBD. ShowDialog (win) = =System.Windows.Forms.DialogResult.OK) {Txtnetuploaddir.text=FBD. SelectedPath; } } Public classWinFormWindow:System.Windows.Forms.IWin32Window {IntPtr _handle; PublicWinformwindow (IntPtr handle) {_handle=handle; } IntPtr System.Windows.Forms.IWin32Window.Handle {Get{return_handle;} } }
WPF Popup folder browse dialog box