Results 1 to 4 of 4

Thread: FTp through FTPGETFILE

  1. #1

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    FTp through FTPGETFILE

    I'm at my wit's end here...

    Message Box Shows FALSE:

    Why? (ipaddress.txt is in the default FTP location)

    Code:
    Public Class Form1
        Inherits System.Windows.Forms.Form
        Public Enum TransferType
            FTP_TRANSFER_TYPE_UNKNOWN = &H0
            FTP_TRANSFER_TYPE_ASCII = &H1   'Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
            FTP_TRANSFER_TYPE_BINARY = &H2  'Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
            INTERNET_FLAG_MUST_CACHE_REQUEST = &H10             'fails if unable to cache request
            INTERNET_FLAG_RESYNCHRONIZE = &H800                 'Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
            INTERNET_FLAG_HYPERLINK = &H400                     'Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.   
            INTERNET_FLAG_RELOAD = &H80000000                   ' retrieve the original item
        End Enum
        Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
        Public Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
        Public Declare Function InternetCloseHandle Lib "wininet" (ByVal hEnumHandle As Long) As Long
        Public Declare Function InternetConnect Lib "wininet" Alias "InternetConnectA" (ByVal hInternet As Long, ByVal lpszServerName As String, ByVal nServerPort As Long, ByVal lpszUserName As String, ByVal lpszPassword As String, ByVal dwService As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
        Public Declare Function InternetGetLastResponseInfo Lib "wininet" Alias "InternetGetLastResponseInfoA" (ByVal lpdwError As Long, ByVal lpszBuffer As String, ByVal lpdwBufferLength As Long) As Long
        Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As FileAttribute, ByVal dwFlags As TransferType, ByRef dwContext As Long) As Boolean
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(292, 266)
            Me.Name = "Form1"
            Me.Text = "Form1"
    
        End Sub
    
    #End Region
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Dim Address As String
            Address = GetSetting("ServerState", "INFO", "FTPURL", "dragonboard.com")
            Dim hConn As Long = 0
            Dim hConn2 As Long = 0
            hConn = InternetOpen("VB", 0, vbNullString, vbNullString, 0)
            hConn2 = InternetConnect(hConn, Address, 0, "myUName", "myPass", 0, 0, 0)
            MsgBox(FtpGetFile(hConn2, "ipaddress.txt", "srvrtmp.txt", 0, 0, 0, 0))
            If hConn > 0 Then InternetCloseHandle(hConn)
            If hConn2 > 0 Then InternetCloseHandle(hConn2)
       End Sub
     
    End Class
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    maybe u have to change the longs by integers......
    \m/\m/

  3. #3

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    I did, it still didnt work,,

    Last DLL Error shows 126

    How do I know what the DLL Errors mean?

    When everything was a long, the error was 6.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  4. #4

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    I'm still stuck on this.

    I have been searching the Internet all day, but so far have found nothing that has fixed the situation.

    Any other ideas?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width