Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to use dirent.h with Visual Studio

📅 2014-Jun-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ visual studio ⬩ 📚 Archive

dirent.h is a header file that is found only on Linux systems. It provides data structures and function calls to open and read the contents of directories. If you are trying to port Linux code that uses this header file to Windows, you will that it is not available with Visual Studio.

Thankfully, there is a Windows implementation of dirent.h which can be downloaded here on Github. Just download the zip file, find the dirent.h header file and place it in your Visual Studio include directory. For example, with Visual Studio Express 2015, this directory is C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include

Tried with: Visual Studio Express 2015 and Windows 7 x64

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧