@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Searches the specified directory of the given FTP session. File and directory entries are returned to the application in the [WIN32_FIND_DATA] structure. !!!!C# Signature: [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr FtpFindFirstFile(IntPtr hConnect, string searchFile, out WIN32_FIND_DATA findFileData, int flags, IntPtr context); !!!!VB Signature: Declare Function FtpFindFirstFile Lib "wininet.dll" _ (ByVal hConnect As IntPtr, ByVal searchFile As String, _ ByRef findFileData As WIN32_FIND_DATA, ByVal flags As Integer, _ ByVal context As IntPtr) As IntPtr !!!!User-Defined Types: [WIN32_FIND_DATA] !!!!Notes: None. !!!!Tips & Tricks: For VB.net FtpFindFirstFile will {or May} return the folder and not a file. Using bRet = InternetFindNextFile(hFind, pData) after FtpFindFirstFile will then return a file. For VAX servers the return string may contain other information e.g. Date modified. This means you will need to parse the text to just get the file name. Placeing the InternetFindNextFile in a do loop will allow you to obtain a list of all the files in the server folder. Note pData here is the storage defined by [WIN32_FIND_DATA]. I have placed the structure I used in this structure information page. !!!!Sample Code: Do ' bRet = InternetFindNextFile(hFind, pData) ' If Not bRet Then Procces the error here and quit Else Pos = InStr(pData.cFileName, " ") ' The file name should be at the start of the line If Pos > 0 Then strItemName = Trim(Left(pData.cFileName, Pos)) ' Get the file name End If ' Add the name to a list - Could be a list box as below or Text box Form1.List_Files.Items.Add(strItemName) Loop ' InternetCloseHandle(hFind) ' close the handle. End Sub !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: FtpFindFirstFile@msdn on MSDN Direct Link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/FtpFindFirstFile.asp
Edit wininet.FtpFindFi...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.