public static MemoryStream CreateShellIdList(string[] paths) { byte[][] pidls = new byte[paths.Length][]; for (int i = 0; i < paths.Length; i++) { PIDL pidl = ILCreateFromPath(paths[i]); pidls[i] = pidl.GetBytes(); } int pidlOffset = 4 * (paths.Length + 2); MemoryStream memoryStream = new MemoryStream(); BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(paths.Length); binaryWriter.Write(pidlOffset); pidlOffset += 4; foreach (byte[] pidl in pidls) { binaryWriter.Write(pidlOffset); pidlOffset += pidl.Length; } binaryWriter.Write(0); foreach (byte[] pidl in pidls) { binaryWriter.Write(pidl); } return(memoryStream); }