Over a million developers have joined DZone.

Browse Windows File System And Get The Path

DZone's Guide to

Browse Windows File System And Get The Path

· ·
Free Resource
This will show a "Browse For Folder" dialog, which doesn't return the path to the folder (some of the folders are "special", and as such don't have a path). The second call returns the full path from the PIDL (an identifier for the chosen folder). This call will throw a COM error if a "special" folder is chosen, so be sure to wrap in a try/catch clause.

SHBrowseForFolder can be called with no args (), which will give you no dialog message.

from win32com.shell import shell

pidl,disp,imglist=shell.SHBrowseForFolder(0,None,"Please choose a directory. Thanks.")

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}