{"id":34863,"date":"2005-07-21T10:00:16","date_gmt":"2005-07-21T10:00:16","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/07\/21\/findfirstfile-is-not-a-sql-query\/"},"modified":"2005-07-21T10:00:16","modified_gmt":"2005-07-21T10:00:16","slug":"findfirstfile-is-not-a-sql-query","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050721-16\/?p=34863","title":{"rendered":"FindFirstFile is not a SQL query"},"content":{"rendered":"<p><a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/fileio\/base\/findfirstfile.asp\"> The <code>FindFirstFile<\/code> function<\/a> is not a SQL query. It&#8217;s a very simple directory enumerator. There is a slightly fancier version called <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/fileio\/base\/findfirstfileex.asp\"> <code>FindFirstFileEx<\/code><\/a>, but even that function doesn&#8217;t add much at present beyond filtering for directories or devices.<\/p>\n<p> You don&#8217;t get to pass it sort criteria like or &#8220;return the files\/directories sorted smallest file first&#8221;, or &#8220;<a href=\"http:\/\/groups.google.com\/groups?selm=cftf1p%245ej%241@hercules.btinternet.com\">return the files\/directories in reverse order of creation<\/a>&#8221; The only filtering you can provide are the wildcard pattern and (if you use <code>FindFirstFileEx<\/code>) a directory filter. The wildcard language is very limited as well; it can&#8217;t express queries like &#8220;files whose extension are either .exe or .dll&#8221; or &#8220;<a href=\"http:\/\/groups.google.com\/groups?selm=MPG.18cd1851de9db08a989a93@news.hinet.hr\">all files whose extension is .c plus all directories regardless of extension<\/a>&#8220;. You also can&#8217;t ask it questions like, &#8220;Tell me the total size of the files in this directory&#8221;, for <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2004\/12\/28\/336219.aspx\"> as we saw earlier<\/a>, this question is underspecified. <\/p>\n<p> If you want to do any of those advanced queries, you&#8217;ll have to code it up yourself. Or as <a href=\"http:\/\/blogs.msdn.com\/hippietim\/\">Hippie Tim<\/a> is fond of saying, &#8220;Start typing!&#8221; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The FindFirstFile function is not a SQL query. It&#8217;s a very simple directory enumerator. There is a slightly fancier version called FindFirstFileEx, but even that function doesn&#8217;t add much at present beyond filtering for directories or devices. You don&#8217;t get to pass it sort criteria like or &#8220;return the files\/directories sorted smallest file first&#8221;, or [&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-34863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The FindFirstFile function is not a SQL query. It&#8217;s a very simple directory enumerator. There is a slightly fancier version called FindFirstFileEx, but even that function doesn&#8217;t add much at present beyond filtering for directories or devices. You don&#8217;t get to pass it sort criteria like or &#8220;return the files\/directories sorted smallest file first&#8221;, or [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34863","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=34863"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34863\/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=34863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=34863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=34863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}