The basic idea is to use the SHBrowseForFolder so as to have the following code:
Private Enum Browseflag
{
Bif_returnonlyfsdirs = 0x0001,//for finding a folder to start document searching
Bif_dontgobelowdomain = 0x0002,//For starting the Find Computer
Bif_statustext = 0x0004,
Bif_returnfsancestors = 0x0008,
Bif_editbox = 0x0010,
Bif_validate = 0x0020,//insist on valid result (or CANCEL)
Bif_browseforcomputer = 0x1000,//browsing for Computers.
Bif_browseforprinter = 0x2000,//browsing for Printers
bif_browseincludefiles= 0x4000//browsing for Everything
}
[StructLayout (LayoutKind.Sequential)]
private struct BROWSEINFO
{
Public IntPtr hWndOwner;
Public IntPtr pidlroot;
[MarshalAs (UNMANAGEDTYPE.LPTSTR)]
public string displayname;
[MarshalAs (UNMANAGEDTYPE.LPTSTR)]
public string title;
public int flags;
Public INTPTR callback;
public INTPTR lparam;
}
StringBuilder sb = new StringBuilder (260);
SHGetPathFromIDList (pidlreturned, SB);
Return SB. ToString ();
}
This is definitely the easiest way to solve the problem. Although no release of pidlreturned may result in a small amount of memory leak, but then a little memory, who cares?
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.