Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I've looked high and low for an answer on this.
I'm connecting VB.NET to our mainframe server using the following command
connect = InternetConnect(hOpen, sPlat, INTERNET_INVALID_PORT_NUMBER, user, pass, INTERNET_SERVICE_FTP, dwSeman, 0)

All is well for this. I can download a file using the FtpGetFile command using the connect variable.

My issue here is trying to create a directory listing for navigation. Seems the easiest way would be to use the FtpFindFirstFile method.

Here is my [relative] code that I am trying:
VB
Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, ByVal lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long

Private Const INTERNET_FLAG_RELOAD = &H80000000
Public Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000

Private Structure WIN32_FIND_DATA
        Public dwFileAttributes As Integer
        Public ftCreationTime As Long
        Public ftLastAccessTime As Long
        Public ftLastWriteTime As Long
        Public nFileSizeHigh As UInteger
        Public nFileSizeLow As UInteger
        Public dwReserved0 As Integer
        Public dwReserved1 As Integer
        Public cFileName As String
        Public cAlternate As String
    End Structure

Public Function GetDirectoryListing(ByVal sFilter As String, ByVal connect As Integer) As IList
'connect passed in with correct connection
'sFilter has been tested with a number of values - latest = "*"
        Dim pData As WIN32_FIND_DATA
        Dim hFind As Integer

        hFind = FtpFindFirstFile(connect, sFilter, pData, INTERNET_FLAG_RELOAD Or INTERNET_FLAG_NO_CACHE_WRITE, 0&)


During run time, I get a warner of "PInvokeStackImbalance was detected"
The error received after executing the step anyway is as follows:
"OverflowException was unhandled
    Arithmetic operation resulted in an overflow"


Any help is appreciated. It would be nice to get a navigation type GUI added to this.
Posted

1 solution

You are returning a long value and trying to fit it into an integer.
Change the variable hFind from integer to long.
 
Share this answer
 
Comments
Charly E Rippenkroeger 21-Oct-10 14:36pm    
You may be a genius. Don't know how I overlooked such an easy one. It got past that. Now the only issue to take care of is it is returning nothing.
LastDllError comes back as 0 (good of course), but everything in pData (WIN32_FIND_DATA) comes back zero or 'Nothing'.
Kschuler 21-Oct-10 14:51pm    
Maybe you should post a new question with this new issue. And include the code inside the FtpFindFirstFile function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900