WPF browsing folder, get its path, wpf folder
Public void GetPath (System. windows. controls. textBox TB) {FolderBrowserDialog FBD = new FolderBrowserDialog (); FBD. description = "select a path"; if (FBD. showDialog () = System. windows. forms. dialogResult. OK) {TB. text = FBD. selectedPath ;}}Obtain the path code private void btnOrg_Click (object sender, RoutedEventArgs e) {GetPath (txtOrgpath );}Call Code
Note: You need to add Winform reference: using System. Windows. Forms;
How can I disable image streams after obtaining all image paths through a folder in wpf?
In your file, files should be of the fileinfo type. after use, you need to dispose, or use the using structure, and it will no longer be occupied.
VB browse folder to get the folder path
The commondialog control can only select files, but cannot select folders. You can select folders using the following code:
Option Explicit
Private Type BrowseInfo
HWndOwner As Long
PIDLRoot As Long
PszDisplayName As Long
LpszTitle As Long
UlFlags As Long
LpfnCallback As Long
LParam As Long
IImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const max_path= 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Function BrowseForFolder (Optional sTitle As String = "select folder") As String
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtraumatic As BrowseInfo
With udtrauma
. HWndOwner = 0 'me. hWnd
. LpszTitle = lstrcat (sTitle ,"")
. UlFlags = BIF_RETURNONLYFSDIRS
End
LpIDList = SHBrowseForFolder (udtraumatic brain injury)
If lpIDList Then
SPath = String $ (MAX_PATH, 0)
SHGetPathFromIDList lpIDList, sPath
CoTaskMemFree lpIDList
INull = InStr (sPath, vbNullChar)
If iNull Then
SPath = Left $ (sPath, iNull-1)
End If
End If
BrowseForFolder = sPath
End Function
Private Sub commandementclick ()
M... the remaining full text>