{"id":520,"date":"2017-03-09T17:12:17","date_gmt":"2017-03-09T16:12:17","guid":{"rendered":"http:\/\/blog.kassebaum.eu\/?p=520"},"modified":"2017-03-09T17:12:17","modified_gmt":"2017-03-09T16:12:17","slug":"tfile-size","status":"publish","type":"post","link":"https:\/\/www.kassebaum.eu\/blog\/2017\/03\/09\/tfile-size\/","title":{"rendered":"TFile.Size"},"content":{"rendered":"<p>I use very often the System.IOUtils units with the wonderful classes\/records TPath, TDirectory and TFile. They are much more comfortable than the old functions from System.SysUtils like FindFirst etc..<\/p>\n<p>But there is one method I&#8217;m really missing: It is the size of a file. For sure there are some workarounds but I think that this method belongs to TFile. That&#8217;s why I wrote a small helper class:<\/p>\n<pre class=\"lang:delphi decode:true\">type\r\n  TFileHelper = record helper for TFile\r\n  public\r\n    class function Size(const APath: string): Int64; static;\r\n  end;\r\n\r\n{ TFileHelper }\r\n\r\nclass function TFileHelper.Size(const APath: string): Int64;\r\nvar\r\n  pStream: TFileStream;\r\nbegin\r\n  pStream := OpenRead(APath);\r\n  try\r\n    Result := pStream.Size;\r\n  finally\r\n    pStream.Free;\r\n  end;\r\nend;\r\n<\/pre>\n<p>I will try to convince Marco or Jim to add this method to the next release. So stay tuned.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use very often the System.IOUtils units with the wonderful classes\/records TPath, TDirectory and TFile. They are much more comfortable than the old functions from System.SysUtils like FindFirst etc.. But there is one method I&#8217;m really missing: It is the &hellip; <a href=\"https:\/\/www.kassebaum.eu\/blog\/2017\/03\/09\/tfile-size\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,31,35,1],"tags":[],"class_list":["post-520","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-rad-studio-10-2-tokyo","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/posts\/520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/comments?post=520"}],"version-history":[{"count":8,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/posts\/520\/revisions"}],"predecessor-version":[{"id":817,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/posts\/520\/revisions\/817"}],"wp:attachment":[{"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kassebaum.eu\/blog\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}