Best way to iterate folders and subfolders

If you’re using .NET 4, you may wish to use the System.IO.DirectoryInfo.EnumerateDirectories and System.IO.DirectoryInfo.EnumerateFiles methods. If you use the Directory.GetFiles method as other posts have recommended, the method call will not return until it has retrieved ALL the entries. This could take a long time if you are using recursion. From the documentation: The EnumerateFilesand … Read more

List all files and directories in a directory + subdirectories

string[] allfiles = Directory.GetFiles(“path/to/dir”, “*.*”, SearchOption.AllDirectories); where *.* is pattern to match files If the Directory is also needed you can go like this: foreach (var file in allfiles){ FileInfo info = new FileInfo(file); // Do something with the Folder or just add them to a list via nameoflist.add(); }

How to use QMake’s subdirs template?

In addition to Troubadour’s comment, I would note that the SUBDIRS target is only good for specifying subdirectories. Therefore, your extra line of SOURCES += main.cpp in your project.pro file is incorrect, and will likely fail to build your main.cpp file, at worst. At best, qmake will refuse to parse the file, since it has … Read more

Rails 4: organize rails models in sub path without namespacing models?

By default, Rails doesn’t add subfolders of the models directory to the autoload path. Which is why it can only find namespaced models — the namespace illuminates the subdirectory to look in. To add all subfolders of app/models to the autoload path, add the following to config/application.rb: config.autoload_paths += Dir[Rails.root.join(“app”, “models”, “{*/}”)] Or, if you … Read more

Using visual basic to access subfolder in Inbox?

Thats very close 🙂 To get all the mail items in a folder called “temp” under the Inbox try this Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim olFolder As Outlook.MAPIFolder Dim msg As Outlook.MailItem Set olApp = Outlook.Application Set objNS = olApp.GetNamespace(“MAPI”) Set olFolder = objNS.GetDefaultFolder(olFolderInbox) Set olFolder = olFolder.Folders(“Temp”) For Each msg … Read more

Browse files and subfolders in Python

You can use os.walk() to recursively iterate through a directory and all its subdirectories: for root, dirs, files in os.walk(path): for name in files: if name.endswith((“.html”, “.htm”)): # whatever To build a list of these names, you can use a list comprehension: htmlfiles = [os.path.join(root, name) for root, dirs, files in os.walk(path) for name in … Read more

How to install Laravel 4 to a web host subfolder without publicly exposing /app/ folder?

So I figured out how to do this. I’ll explain with an example. Suppose you a domain, http://domain.example. Here’s an example of the structure you might be using: domain.example/ (the root of your web hosting) |– yourlaravel4_base/ |– [some other folders…] |– public_html/ (where your html files and such go) | |– [some other folders…] … Read more