WPF browsing folder, get its path, wpf folder

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.