{"id":103014,"date":"2019-10-21T07:00:00","date_gmt":"2019-10-21T14:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103014"},"modified":"2019-10-20T20:20:28","modified_gmt":"2019-10-21T03:20:28","slug":"20191021-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20191021-00\/?p=103014","title":{"rendered":"When I tell the file or folder picker that I want only file system files and folders, why does it still show virtual folders?"},"content":{"rendered":"<p>You can ask a file picker dialog to limit itself to files in the file system by passing the <code>FOS_<\/code><code>FORCE\u00adFILE\u00adSYSTEM<\/code> flag. There is an analogous <code>BIF_<\/code><code>RETURN\u00adONLY\u00adFS\u00adDIRS<\/code> flag for the folder picker.<\/p>\n<p>But if you pass this flag, you&#8217;ll still see virtual folders in the user interface. Things like <i>Network<\/i> and <span style=\"text-decoration: line-through;\"><i>My Computer<\/i><\/span> <i>This PC<\/i>. And if the user picks it, the OK button grays out, which is confusing. Why are these virtual folders showing up when I explicitly asked that they not show up?<\/p>\n<p>Well, that&#8217;s not what you asked.<\/p>\n<p>You asked that the user be able to select only file system files or folder. You didn&#8217;t ask that non-file-system object be removed from view.<\/p>\n<p>But why are these non-file-system objects shown in the view if the user can&#8217;t select them?<\/p>\n<p>Because there might be a file system object <i>inside<\/i> them.<\/p>\n<p>The shell namespace has two attributes related to the file system. One is <code>SFGAO_<\/code><code>FILE\u00adSYSTEM<\/code>, which means that the item is itself in the file system. The other is <code>SFGAO_<\/code><code>FILE\u00adSYS\u00adANCESTOR<\/code> which means that the item <i>or its children<\/i> are in the file system.<\/p>\n<p>If an item has the <code>SFGAO_<\/code><code>FILE\u00adSYS\u00adANCESTOR<\/code> attribute, then it will show up in the &#8220;make sure the user picks an item in the file system&#8221; dialogs: Even if the item itself is not a file system item, it may <i>contain<\/i> a file system item, so the dialog shows the item so the user can navigate into it to find the actual file system item.<\/p>\n<p>The <code>SFGAO_<\/code><code>FILE\u00adSYS\u00adANCESTOR<\/code> attribute is like a sign that says &#8220;This way to the file system.&#8221;<\/p>\n<p>If the file and folder picker dialogs showed only file system objects and not also file system ancestors, then your dialog would be pretty blank, seeing as the root items like <i>This PC<\/i> and <i>Network<\/i> are themselves not file system items. But if you want to pick something from your D: drive, you&#8217;ll probably need to go through <i>This PC<\/i> to get there.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Because there might be a file hiding under it.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-103014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Because there might be a file hiding under it.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=103014"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103014\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=103014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}