Much of .NET's source code is openly available on https://referencesource.microsoft.com.
If you look at the source code for the System.IO.Directory class, its GetFiles() method creates a TList<String> using an IEnumerable<String> from FileSystemEnumerableFactory.CreateFileNameIterator(), and then converts that TList<String> to a String[] array, where FileSystemEnumerableIterator internally uses the Win32 API FindFirstFile() and FindNextFile() functions.
So, the statement:
String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
Would be roughly equivalent to the following C++ code using the Win32 API directly:
#include <windows.h>
#include <string>
#include <vector>
std::vector<std::wstring> listOfPipes;
std::wstring prefix(L"\\\\.\\pipe\\");
WIN32_FIND_DATAW fd;
HANDLE hFind = FindFirstFileW((prefix + L"*").c_str(), &fd);
if (hFind == INVALID_HANDLE_VALUE)
{
// error handling...
}
else
{
do
{
listOfPipes.push_back(prefix + fd.cFileName);
}
while (FindNextFileW(hFind, &fd));
// error handling...
FindClose(hFind);
}