public static extern IntPtr FtpFindFirstFile([In] IntPtr hConnect, [In] string searchFile, [In][Out] ref WINAPI.WIN32_FIND_DATA findFileData, [In] int dwFlags, [In] IntPtr dwContext);
private List <string> List(string mask, bool onlyDirectories) { WINAPI.WIN32_FIND_DATA findFileData = default; var intPtr = WININET.FtpFindFirstFile(_hConnect, mask, ref findFileData, 67108864, IntPtr.Zero); try { var list = new List <string>(); if (intPtr == IntPtr.Zero) { if (Marshal.GetLastWin32Error() == 18) { return(list); } Error(); return(list); } if (onlyDirectories && (findFileData.dfFileAttributes & 0x10) == 16) { var list2 = list; var text = new string(findFileData.fileName); var trimChars = new char[1]; list2.Add(text.TrimEnd(trimChars)); } else if (!onlyDirectories) { var list3 = list; var text2 = new string(findFileData.fileName); var trimChars2 = new char[1]; list3.Add(text2.TrimEnd(trimChars2)); } findFileData = default; while (WININET.InternetFindNextFile(intPtr, ref findFileData) != 0) { if (onlyDirectories && (findFileData.dfFileAttributes & 0x10) == 16) { var list4 = list; var text3 = new string(findFileData.fileName); var trimChars3 = new char[1]; list4.Add(text3.TrimEnd(trimChars3)); } else if (!onlyDirectories) { var list5 = list; var text4 = new string(findFileData.fileName); var trimChars4 = new char[1]; list5.Add(text4.TrimEnd(trimChars4)); } findFileData = default; } if (Marshal.GetLastWin32Error() != 18) { Error(); } return(list); } finally { if (intPtr != IntPtr.Zero) { WININET.InternetCloseHandle(intPtr); } } }
public static extern int InternetFindNextFile([In] IntPtr hInternet, [In][Out] ref WINAPI.WIN32_FIND_DATA findData);