Ftpputfile

Erdenemandal

Well-known member
Joined
Jul 5, 2004
Messages
63
Location
Deutschland
HI AL

I am using VB.NET . But my script does not fit into VB.NET

I want to uplado file to server,

This is my CODE

Thanks,
Erdenemandal
Code:
 Private 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
  Private 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
Private 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


 Me.mOPenHandler = InternetOpen("Curavis", Me.INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)

Me.hConnectedHandle = InternetConnect(mOPenHandler, "192.168.0.96", 21, userName, userPAss, 1, 0, 0)
If FtpPutFile(Me.hConnectedHandle, "C:\dirmap.txt", "/home/erdene/tssest.htm", &H0, 0) Then
                                MsgBox("OK")
                        Else
                                MsgBox("ONONO")
                                MsgBox(GetLastError.ToString)
                        End If
 
It is working NOW

Hi, ALL

I change as long into as integer, And it works . This is a code

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim INet, INetConn As Integer
                Dim RC As Boolean
                INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

                INetConn = InternetConnect(INet, "192.168.2.96", 0, userName, UserPass, 1, 0, 0)
                RC = FtpPutFile(INetConn, "c:\dirmap.txt", "/tmp/sss.sss", 1, 0)


                If RC Then MessageBox.Show("Transfer succesfull!")

                InternetCloseHandle(INetConn)
                InternetCloseHandle(INet)
        End Sub

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
                Dim INet, INetConn As Integer
                Dim RC As Boolean
                INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)

                INetConn = InternetConnect(INet, "192.168.2.96", 0, userName, userPass, 1, 0, 0)
                RC = FtpGetFile(INetConn, "/tmp/sss.sss", "c:\temp\ssss.ext", True, 1, 0, 0)
                If RC Then MessageBox.Show("Transfer succesfull!")

                InternetCloseHandle(INetConn)
                InternetCloseHandle(INet)
        End Sub


this is a declaraiton


Code:
 Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer

        Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer

        Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer


        Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean


        Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
 
Back
Top