Ruby win32ole Gem with OLE error 800A004C (Path Not Found) for size method <p>I have a colossal directory on my hard-drive and I wanted to gather some stats so I began writing a script. To speed things up massively I used Windows OLE but I've come across an interesting issue where the the <code>ar2</code> OLE object has a method called <code>size</code> but calling it gives me error <code>800A004C</code> or "Path Not Found". I have also tested on other directories and the below code works perfectly fine.</p> <p>I have used the method <code>ole_methods</code> and double checked the casing on <code>size</code>. The OLE method in Ruby definitely exists but no dice on getting it to succeed.</p> <p>Why is Windows OLE throwing this error when it should know the folder exists and compute the overall size of the folder structure recursively?</p> <pre><code>require 'win32ole' def getFileCount(dir) size = dir.Files.count sub_folders = dir.SubFolders unless sub_folders == 0 sub_folders.each do |sub| size += getFileCount(sub) end end size end AR2_NAME = ARGV[0] FSO = WIN32OLE.new("Scripting.FileSystemObject") ar2 = FSO.GetFolder(AR2_NAME) ar2_file_count = getFileCount(ar2) puts "Stats for #{ar2.path}.\n\n" puts "Total file count: #{ar2_file_count}." puts "Total size: #{ar2.size}." </code></pre> <p>Run the file using </p> <pre><code>Ruby C:\sample.rb "C:\my_folder" </code></pre> <p>Here's the error in question:</p> <p><a href="https://i.stack.imgur.com/WNn3t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WNn3t.png" alt="The error in question"></a></p> <p>The folder's size is 1,492,503,618,641 bytes (1.35 TB) according to Windows. It is over 100k files.</p> <p>I have included my recursive file counting method as this works and illustrates that my folder does indeed exist.</p>