/// <summary> /// Gets all of the info for files within the given directory handle. /// </summary> public unsafe static IEnumerable <FullFileInformation> GetDirectoryInformation(SafeFileHandle directoryHandle) { List <FullFileInformation> infos = new List <FullFileInformation>(); GetFullDirectoryInfoHelper(directoryHandle, buffer => { FILE_FULL_DIR_INFORMATION *info = (FILE_FULL_DIR_INFORMATION *)buffer.BytePointer; do { infos.Add(new FullFileInformation(info)); info = FILE_FULL_DIR_INFORMATION.GetNextInfo(info); } while (info != null); }); return(infos); }
/// <summary> /// Gets the filenames in the specified directory. Includes "." and "..". /// </summary> public unsafe static IEnumerable <string> GetDirectoryFilenames(SafeFileHandle directoryHandle) { List <string> filenames = new List <string>(); GetFullDirectoryInfoHelper(directoryHandle, buffer => { FILE_FULL_DIR_INFORMATION *info = (FILE_FULL_DIR_INFORMATION *)buffer.BytePointer; do { filenames.Add(info->FileName.CreateString()); info = FILE_FULL_DIR_INFORMATION.GetNextInfo(info); } while (info != null); }); return(filenames); }