{"id":11823,"date":"2011-01-05T07:00:00","date_gmt":"2011-01-05T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/01\/05\/why-does-shgetspecialfolderpath-take-such-a-long-time-before-returning-a-network-error\/"},"modified":"2011-01-05T07:00:00","modified_gmt":"2011-01-05T07:00:00","slug":"why-does-shgetspecialfolderpath-take-such-a-long-time-before-returning-a-network-error","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110105-00\/?p=11823","title":{"rendered":"Why does SHGetSpecialFolderPath take such a long time before returning a network error?"},"content":{"rendered":"<p>A customer reported that their program was failing to start up because the call to <code>SHGet&shy;Special&shy;Folder&shy;Path(CSIDL_PERSONAL)<\/code> was taking a long time and then eventually returning with <code>ERROR_BAD_NETPATH<\/code>. The account that was experiencing this problem had a redirected network profile, &#8220;but even if he&#8217;s redirecting, why would we get the bad net path error? Does calling <code>SHGet&shy;Folder&shy;Path<\/code> actually touch the folder\/network? If so, we should probably stop calling this function on the UI thread since network problems could cause our program to hang.&#8221;\n The <code>SHGet&shy;Folder&shy;Path<\/code> function will access the network if you pass the <code>CSIDL_FLAG_CREATE<\/code> flag, which says &#8220;Check if the folder is there, and if not, create it.&#8221;\n The customer had been passing the flag. &#8220;We&#8217;ll remove it. As if our program is going to dictate the creation of the user profile directory.&#8221;\n The <code>CSIDL_FLAG_CREATE<\/code> flag has been implicated in some other unwanted behavior. For example, if you pass the <code>CSIDL_FLAG_CREATE<\/code> flag when asking for <code>CSIDL_MYPICTURES<\/code>, this will create a <i>My Pictures<\/i> directory if there wasn&#8217;t one before. Generally speaking, you shouldn&#8217;t be creating these directories as side-effects of other actions. Corporate administrators may suppress creation of folders like <i>Pictures<\/i> and <i>Videos<\/i>, but that doesn&#8217;t do much good if your program casually creates them as part of its startup.<\/p>\n<p> Note that <code>SHGet&shy;Special&shy;Folder&shy;Path<\/code> and <code>CSIDL<\/code> values have been superseded by <code>SHGet&shy;Known&shy;Folder&shy;Path<\/code> and <code>KNOWN&shy;FOLDER&shy;ID<\/code>. The flag corresponding to <code>CSIDL_FLAG_CREATE<\/code> is <code>KF_FLAG_CREATE<\/code>. If you want to make things even faster, consider passing the <code>KF_FLAG_DONT_VERIFY<\/code> flag (formerly known as <code>CSIDL_FLAG_DONT_VERIFY<\/code>). <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer reported that their program was failing to start up because the call to SHGet&shy;Special&shy;Folder&shy;Path(CSIDL_PERSONAL) was taking a long time and then eventually returning with ERROR_BAD_NETPATH. The account that was experiencing this problem had a redirected network profile, &#8220;but even if he&#8217;s redirecting, why would we get the bad net path error? Does calling [&hellip;]<\/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-11823","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer reported that their program was failing to start up because the call to SHGet&shy;Special&shy;Folder&shy;Path(CSIDL_PERSONAL) was taking a long time and then eventually returning with ERROR_BAD_NETPATH. The account that was experiencing this problem had a redirected network profile, &#8220;but even if he&#8217;s redirecting, why would we get the bad net path error? Does calling [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11823","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=11823"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/11823\/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=11823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=11823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=11823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}